Author Topic: sorting queues  (Read 25828 times)

Alfonso V

  • Guest
sorting queues
« on: September 21, 2004, 09:35:39 AM »
Hi

Somewhere I have readed it is not necessary define heads for single queues, but I'm not agree with this because I think it is necessary for sorting them. Is there any one who think different?. If we want sort a queue (lists in general) we need an entry point, so a head.

Thak you

Alfonso V

  • Guest
Re: sorting queues
« Reply #1 on: September 21, 2004, 12:57:55 PM »
Explain myself:

Suppose we have next structures

myStructure:
position.. data.. pointer
104....... ?...... 108
108....... 5...... 10C
10C....... 1...... 110
110....... 4...... 114
114....... 3...... 0

yourStructure:
position.. data.. pointer
104....... 5...... 108
108....... 1...... 10C
10C....... 4...... 110
110....... 3...... 0


I Can sort myStructure:
position.. data.. pointer
104....... ?...... 10C
108....... 5...... 0
10C....... 1...... 114
110....... 4...... 108
114....... 3...... 110

And I can print it
(10C) 1 (114) 3 (110) 4 (108) 5 (0 *end*)


We can sort also your structure:
position.. data.. pointer
104....... 5....... 0
108....... 1....... 110
10C....... 4....... 104
110....... 3....... 10C

But, how can you write it without a pointer (head) to 108 position?