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 ( maximum
element ) while set and heap can erase any element ... 3 7436
On Aug 8, 12:44 pm, PicO <bekerp...@gmai l.comwrote:
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 ( maximum
element ) while set and heap can erase any element ...
i also read that .. i can make a heap from priority queue ....
how ? ...
PicO wrote:
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 ( maximum
element ) while set and heap can erase any element ...
The advantage of a priority queue (in cases where you just need the
smallest item in a group of values) over a set is that the priority
queue will take much less memory. A priority queue can be constructed
into a vector (ie. a contiguous array) and thus it will only require
as much memory as the sizes of the elements. A set will take much more
memory (because besides the elements themselves it needs 3 pointers
per element, plus the additional overhead caused by allocating each
element dynamically).
On Aug 9, 3:18 am, Juha Nieminen <nos...@thanks. invalidwrote:
PicO wrote:
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 ( maximum
element ) while set and heap can erase any element ...
The advantage of a priority queue (in cases where you just need the
smallest item in a group of values) over a set is that the priority
queue will take much less memory. A priority queue can be constructed
into a vector (ie. a contiguous array) and thus it will only require
as much memory as the sizes of the elements. A set will take much more
memory (because besides the elements themselves it needs 3 pointers
per element, plus the additional overhead caused by allocating each
element dynamically).
thanks juha .. that's i want the smallest one so I'll use priority
queue ... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 queue. However, no
matter what reasonably-sized type I use for the stamp, eventually the
stamp will 'wrap around' and possibly cause incorrect ordering of
elements. For my application, which queues elements very quickly and
runs for an...
|
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 all from you
|
by: Stuart Golodetz |
last post by:
Hi guys,
Just wondering what you'd recommend in terms of a C++ priority queue
implementation that supports bubble-up and bubble-down operations
please? std::priority_queue doesn't seem to support doing that, and I
couldn't find an alternative in Boost. I could write my own, but that
feels a little bit like reinventing the wheel, so I thought it was worth
asking first.
Cheers,
|
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 priority queue, which is an array heap, and for example i/2 is the father of i and so on..
the code of the static priority queue is this:
int i= ++CurrentSize;
while(i != 1 && X > heap) {
// cannot put x in heap
heap = heap; //move...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |