By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,338 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,338 IT Pros & Developers. It's quick & easy.

Merging of priority queue

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

Jan 24 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a


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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.