Merging of priority queue

  • Thread starter Thread starter vidishasharma
  • Start date Start date
V

vidishasharma

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

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 <--
 
Will conquer step from the merge sort algorithm be good enough for
merging of priority queues.

can you suggest some good URL
 
I am missing something. Why not just copy the arrays to a new array or
queue?

--
William Stacey [C# MVP]

|
|
| 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 <[email protected]>
| wrote:
| > hi,
| >
| > (e-mail address removed) 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 <--
|
 
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 <--
 
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]

| 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 <--
 
hi William,
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 <--
 
hi William,
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 <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top