Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1(a)What are some practical applications for queues, priority queues and deques?

ID: 3874813 • Letter: 1

Question

1(a)What are some practical applications for queues, priority queues and deques? and what are the options for implementing these three data structures, and what are the pros and cons for each approach?

1(b)What scenarios will make it more appropriate to use iteration over recursion and vice versa? Please provide specific examples along with research and justification for your choice.

1(c) Compare the two implementations for binary trees: linked lists vs. arrays. Discuss the pros and cons for each approach considering the key operations you need to perform for these trees including the different types of traversals.

Explanation / Answer

Question 1

Queue are used in situation where the First in first out needs to be maintained efficeintly.It is used in the use of printer where the jobs are solved in a first come first serve basis.

Priority queues are used where the first in first out to be handled but also the priority needs to be maintained.Lets take a scenario in a hospital there is one doctor and patients are coming one after the other.First a patient came it is attended by the doctor.In the meantime anothere patient came with stomach pain is added to the queue.After that anoher patient came with head ache that is also added to the queue.Then a patient came with fracture in head.So here the patient is moved to the front as it is having higher medical emergecny.So in this way the line is maintained.

A practical example of dequeue would be the scenario of how tha URL is managed in the web browser.The newly used URL is added at the front of the queue whereas the old URLs are deleted from the back after some insertion in the queue.

Queue

Advantange
a.Queue helps to carry out process using FIFO manner.

b.It can be used to work with different data types.

Disadvantage
a.New Elements can only be inserted when all the old elements are deleted from the queue.

Priority Queue

Advantage
a.Based on the weight value of the nodes they are moved accordingly.
b.It is easy to implement compared to others.

Disadvantage
a.Slower than other data structures as it uses lot of space to store n number of records.

Dequeue

Advantage
a.Insertion and deletion can be done at the same time.

Question 2

First of all there is no such fixed scenarios in which recurison is used over iteration.Whatever iteration can do can also be done with the help of recursion and vice versa.The main plus point of using recursion will be that the code size decreases.Let us take a situation , We have to find a key in the binary search tree and we are able to find the key before the half of the tree has been parsed.So here in case of recursion it will continue to go on for the full parse of the binary tree but whereas using iteration it can be exited easily.THese are the small scenario which can be taken into consideration.

Question 3

Using array for implementaion of binary tree

Advantage
a.Searching the element will be easy rather time complexity will be less in case of less number of element.

Disadvantage
a.Time Complexity increases at times while using large number of elements.
b.High cost is incurred while inserting a element in the present structure.

Using Linked list for implementaion of binary tree

Advantage
a.Insertion of element will incurr less cost.
b.Dyniamice size can be implemented

Disadvantage
a.Random access is not possilbe.