473,395 Members | 1,516 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,395 software developers and data experts.

Merging of priority queue

Can somebody suggest good URL which contains code for merging of 2 or
more priority queues in c#.

Jan 24 '07 #1
8 3647
hi,

vi***********@gmail.com wrote:
Can somebody suggest good URL which contains code for merging of 2 or
more priority queues in c#.
Use the conquer step from the merge sort algorithm.
mfG
--stefan <--

Jan 24 '07 #2


Will conquer step from the merge sort algorithm be good enough for
merging of priority queues.

can you suggest some good URL

On Jan 24, 6:32 pm, Stefan Hoffmann <stefan.hoffm...@explido.de>
wrote:
hi,

vidishasha...@gmail.com wrote:
Can somebody suggest good URL which contains code for merging of 2 or
more priority queues in c#.Use the conquer step from the merge sort algorithm.

mfG
--stefan <--
Jan 25 '07 #3
I am missing something. Why not just copy the arrays to a new array or
queue?

--
William Stacey [C# MVP]

<vi***********@gmail.comwrote in message
news:11**********************@13g2000cwe.googlegro ups.com...
|
|
| Will conquer step from the merge sort algorithm be good enough for
| merging of priority queues.
|
| can you suggest some good URL
|
| On Jan 24, 6:32 pm, Stefan Hoffmann <stefan.hoffm...@explido.de>
| wrote:
| hi,
| >
| vidishasha...@gmail.com wrote:
| Can somebody suggest good URL which contains code for merging of 2 or
| more priority queues in c#.Use the conquer step from the merge sort
algorithm.
| >
| mfG
| --stefan <--
|
Jan 25 '07 #4
hi William,

William Stacey [C# MVP] write:
I am missing something. Why not just copy the arrays to a new array or
queue?
Then the queue itself has to (re-)sort it, but it's the same problem.
mfG
--stefan <--
Jan 25 '07 #5
hi,

vi***********@gmail.com wrote:
Will conquer step from the merge sort algorithm be good enough for
merging of priority queues.
http://en.wikipedia.org/wiki/Merge_sort

But as William asked, does your priority queue not already have
AddRange() or a similar method to add another queue?
mfG
--stefan <--
Jan 25 '07 #6
But they are already in sorted order, so you they just follow set1, set2,
set3, etc. Or is this not how you want them? What is the sort key, what do
you want?

--
William Stacey [C# MVP]

"Stefan Hoffmann" <st*************@explido.dewrote in message
news:u7**************@TK2MSFTNGP06.phx.gbl...
| hi William,
|
| William Stacey [C# MVP] write:
| I am missing something. Why not just copy the arrays to a new array or
| queue?
| Then the queue itself has to (re-)sort it, but it's the same problem.
|
|
| mfG
| --stefan <--
Jan 25 '07 #7
hi William,

William Stacey [C# MVP] wrote:
But they are already in sorted order, so you they just follow set1, set2,
set3, etc.
You have to compare the first item from set1 with the other first items
of the other sets.

Queue #1: 6 5 4
Queue #2: 7 3 2
Queue #3: 9 8 1

Then you can copy the correct element.

That is what merge sort does using two queues.
mfG
--stefan <--

Jan 25 '07 #8
hi William,

William Stacey [C# MVP] schrieb:
But they are already in sorted order, so you they just follow set1, set2,
set3, etc.
When copying each element of each set the queue is sorted. But you need
to compare for each set element to copy.

Using the merge step from the merge sort algorithm, the steps can be
reduced. In the worst case you need the same amount of steps. Generally
you need lesser steps. So it would be faster.
mfG
--stefan <--
Jan 25 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

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 (...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...

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.