search
Log In

Recent questions tagged priority-queue

0 votes
2 answers
1
A priority queue is implemented as a Max-Heap. Initially, it has $5$ elements. The level-order traversal of the heap is: $10,8,5,3,2$. Two new elements $1$ and $7$ are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is $10,8,7,3,2,1,5$ $10,8,7,2,3,1,5$ $10,8,7,1,2,3,5$ $10,8,7,5,3,2,1$
asked Mar 30 in DS Lakshman Patel RJIT 53 views
1 vote
1 answer
2
What is the worst case time of insert and extract- min in an implementation of a priority queue using an unsorted array? Assume that all insertions can be accommodated 1) θ(1) ,θ(n) 2) θ(n) ,θ(1) 3) θ(1) ,θ(1) 4) θ(n) ,θ(n)
asked Dec 22, 2019 in Algorithms Sanjay Sharma 359 views
0 votes
0 answers
3
Show how to implement a first-in, first-out queue with a priority queue. Show how to implement a stack with a priority queue.
asked Jun 27, 2019 in Algorithms akash.dinkar12 41 views
0 votes
0 answers
4
Is priority queue work efficiently with sorted array than unsorted array and heap for insertion and deletion operation? Then why do we apply priority queue in heap specially
asked Dec 22, 2018 in DS srestha 175 views
0 votes
1 answer
5
0 votes
1 answer
6
On other sources, it is given that we need to assign high priorities to newly inserted element in case of stack otherwise low priority to newly inserted element in case of queue. My doubt here is that shouldn't stack be implemented with max-heap priority queue and queue with min-heap priority queue keeping above assumption of assigning priorities to newly inserted element?
asked Jun 17, 2018 in Algorithms pallaviamu 524 views
1 vote
2 answers
7
Suppose Stack operations are implemented using Queue Operation. Push(x) and Pop() are stack operations whereas enqueue(x) and dequeue are Queue operations. Consider the code: pop() { return Q.dequeue(); } push(x) { n= Q.size(); //Q.size() returns the number of elements in the Queue ... () operation correctly (A) Q.enqueue(x) (B) Q.enqueue(Q.deqeue()) (C) Q.dequeue(Q.enqueue(x)) (D) Q.dequeue()
asked Nov 12, 2017 in DS Parshu gate 507 views
0 votes
1 answer
8
How to implement Priority queue using stack?What will be time complexity for Enqueue and Dequeue operations? Edit:- Updated the question clearly
asked Dec 18, 2016 in Programming rahul sharma 5 433 views
1 vote
1 answer
9
A priority queue is implemented as a max-heap. Initially, it has five elements. The levelorder traversal of the heap is as follows : 20, 18, 15, 13, 12 Two new elements 10' and 17' are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the element is : 20, ... , 12, 10 20, 18, 17, 12, 13, 10, 15 20, 18, 17, 10, 12, 13, 15 20, 18, 17, 13, 12, 10, 15
asked Oct 1, 2016 in DS makhdoom ghaya 994 views
0 votes
1 answer
10
What is the most appropriate data structure to implement a priority queue ? Heap Circular array Linked list Binary tree
asked Sep 16, 2016 in DS makhdoom ghaya 709 views
1 vote
1 answer
11
How many minimum queues are required to implement a priority queue?
asked Jun 22, 2016 in DS tripathiambuj 678 views
34 votes
3 answers
12
A priority queue $Q$ is used to implement a stack that stores characters. PUSH (C) is implemented as INSERT $(Q, C, K)$ where $K$ is an appropriate integer key chosen by the implementation. POP is implemented as DELETEMIN$(Q)$. For a sequence of operations, the keys chosen are in non-increasing order non-decreasing order strictly increasing order strictly decreasing order
asked Sep 29, 2014 in DS Kathleen 6.2k views
To see more, click for the full list of questions or popular tags.
...