473,382 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Priority Queue

Parul Bagadia
188 100+
In case of applying deleting operation on ascending priority queue; elements are retrieved in ascending order.. however if a small element is inserted after several deletions; the next retrival will return that smsller element, which may be smaller than a previously retrieved element...
Above is the statement given in the book of Data Structures by Tenenbaum; but logically always the smallest item should be deleted, isn't it so?
Apr 1 '08 #1
4 2641
Ganon11
3,652 Expert 2GB
In a priority queue, a deleteMin operation deletes the smallest element currently in the queue. It has no effect on elements that might enter the queue at a later time - how could it possibly do that?

In your example, you may have had a queue with the values 1, 2, 4, 5, and 6 in it. So you deleteMin 3 times and get (in order) 1, 2, and 4. Now I add 3 to the queue. It is now the smallest element in the queue (i.e. it is smaller than 5 and 6), so the next deleteMin will give 3.
Apr 1 '08 #2
Parul Bagadia
188 100+
In a priority queue, a deleteMin operation deletes the smallest element currently in the queue. It has no effect on elements that might enter the queue at a later time - how could it possibly do that?

In your example, you may have had a queue with the values 1, 2, 4, 5, and 6 in it. So you deleteMin 3 times and get (in order) 1, 2, and 4. Now I add 3 to the queue. It is now the smallest element in the queue (i.e. it is smaller than 5 and 6), so the next deleteMin will give 3.
No, here my point is the following statement..
however if a small element is inserted after several deletions; the next retrival will return that smaller element, which may be smaller than a previously retrieved element...
which means that after several deletions if i add up some elements; still the smaller of the previously retrieved element will be retrieved.
Apr 2 '08 #3
sicarie
4,677 Expert Mod 4TB
No, here my point is the following statement..
however if a small element is inserted after several deletions; the next retrival will return that smaller element, which may be smaller than a previously retrieved element...
which means that after several deletions if i add up some elements; still the smaller of the previously retrieved element will be retrieved.
Parul-

Please slow down and write this out, work it out on paper, on the computer, however works best for you - Ganon has answered you appropriately.

1) a priority queue - 1, 2, 4, 5, 6

2) after several deletions - so we remove 1, 2, and 4 - this queue is now 5, 6

3) if a mall element is inserted - say 3, so the queue is now 3, 5, 6

4) the next retrieval will return that element - the smallest element in the queue is 3, so that is the one returned

Does that answer your question, or is there a specific part/wording you have having trouble with?
Apr 2 '08 #4
Parul Bagadia
188 100+
Parul-

Please slow down and write this out, work it out on paper, on the computer, however works best for you - Ganon has answered you appropriately.

1) a priority queue - 1, 2, 4, 5, 6

2) after several deletions - so we remove 1, 2, and 4 - this queue is now 5, 6

3) if a mall element is inserted - say 3, so the queue is now 3, 5, 6

4) the next retrieval will return that element - the smallest element in the queue is 3, so that is the one returned

Does that answer your question, or is there a specific part/wording you have having trouble with?
Oh yaeh, i got it.
Thank you very much.
Actually i made a mistake in understanding.
Thanx again.
Apr 2 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

38
by: Aaron W. LaFramboise | last post by:
Hello, I understand that an easy way to make the standard std::priority_queue stable is by including an integer stamp with each node that is incremented each time a new node is pushed into the...
5
by: Dan H. | last post by:
Hello, I have implemented a C# priority queue using an ArrayList. The objects being inserted into the priority queue are being sorted by 2 fields, Time (ulong) and Priority (0-100). When I...
3
by: Erik | last post by:
Hi Everyone, I was thinking of how to do this for a while now and I cant get my head round it so I though I'd ask the experts! :-) What I am doing is reading in large amounts of data over TCP...
16
by: Crirus | last post by:
hello I read somewhere about priority queue...what is that and Vb net have such class? -- Ceers, Crirus ------------------------------ If work were a good thing, the boss would take it...
4
by: vfunc | last post by:
Is the STL priority queue a proper implementation of a heap with siftup algorithm etc ? How do you implement an STL priority queue (link to an example) ? Is there a resort method, why ? Thanks
3
by: Chris Lasher | last post by:
Hello, I am working with large graphs (~150,000 to 500,000 nodes) which I need decompose node-by-node, in order of a node's value. A node's value is determined by the sum of its edge weights....
3
by: PicO | last post by:
i need some explanation about the difference between priority queue & set & heap ... as they all sort the data in ( n log n ) ... but the only i see that priority queue only can pop the top (...
1
by: operatingsystem | last post by:
I need to generate such scheduler in operating system subject which satisfy below conditions...may i request u if anybody knows abt this plz help me out in this..topics.. Scheduler...
4
by: jjh5030 | last post by:
This is a programming assignment. You are asked to work with pointers. Be aware that error messages are often not very helpful when your pointers point to bad locations. Therefore, reserve...
14
by: AlarV | last post by:
Hello everyone, here is my problem. I have to make a dynamic priority queue,which is a heap, and my book isn't helpful at all, so I have no clues on how to create it.. I read something like a static...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.