flat assembler
Message board for the users of flat assembler.

Index > Main > sorting queues

Author
Thread Post new topic Reply to topic
avcaballero



Joined: 02 Feb 2004
Posts: 203
Location: Madrid - Spain
avcaballero 21 Sep 2004, 08:59
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
Post 21 Sep 2004, 08:59
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 21 Sep 2004, 10:46
It depends - you don't HAVE TO but it's easier to have them
Like in school you are given an assignment to reverse a string
witout asking its length or even making new variables Neutral
It would be a lot easier to reverse a string if you know its length
beforehand but its ingenious to solve without it Wink

We wouldn't be assembly programmers if we didn't like these
algorithm solution findings Very Happy
Post 21 Sep 2004, 10:46
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 203
Location: Madrid - Spain
avcaballero 21 Sep 2004, 12:49
Hi Madis731

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?
Post 21 Sep 2004, 12:49
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 25 Sep 2004, 07:11
Ok, that is another subject
Here you have a linked list and then you must have something
to end it, and this list doesn't even have to be in one memory
area. What I was thinking is sorting them in place so this array
5,1,4,3 can be arranged to 1,3,4,5 or 5,4,3,1 and the first one
is always assumed to be the 1st by the program.

But...if you really wanna get tricky you could have two pointers
in each structure: next position(bigger) and the last position
(smaller). So whenever you trip on one structure, you can find
them all, but then you MUST have a head and a tail.
Post 25 Sep 2004, 07:11
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.