flat assembler
Message board for the users of flat assembler.

 Index > Main > sorting queues
Author
avcaballero

Joined: 02 Feb 2004
Posts: 193
avcaballero
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
21 Sep 2004, 08:59

Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
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
It would be a lot easier to reverse a string if you know its length
beforehand but its ingenious to solve without it

We wouldn't be assembly programmers if we didn't like these
algorithm solution findings
21 Sep 2004, 10:46
avcaballero

Joined: 02 Feb 2004
Posts: 193
avcaballero

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?
21 Sep 2004, 12:49

Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
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.
25 Sep 2004, 07:11
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum