Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i mean sort each element by giving them priority in linked list class, if one element is sorted first than set it to the beginning of the queue i tried but didn't get that result
Posted
Comments
Sergey Alexandrovich Kryukov 1-Dec-11 15:42pm    
Not a question. This approach does not seem to have much sense.
Further discussion is possible only if your share your ultimate goals.
--SA
Philippe Mori 1-Dec-11 19:53pm    
Give us the class name you are using. A LinkedList is not a priority queue. Maybe are you talking about a sorted list? As far as I known, there is not priority queue in .NET (except if you use STL/CLR).

Anyway, you should give us your source code so we would see what you are trying to do.

There are thousand of ways of doing bad code so if your actual code does not works, we cannot guess what is your code and thus cannot help you much.

And if you were really using a priority queue and the code is correct then it would works.

1 solution

CodeProject is your friend: see: "Priority queue in C# with the help of heap data structure" by Alexey Kurakin, May 2011[^].

I'd decompose your solution into two parts: one implementing a priority queue, and then the task of creating/refreshing a Linked List sorted based on the priority queue.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900