Board index » delphi » Index Search + Quick Sort

Index Search + Quick Sort

can someone please help...
please just explain the theory behind an index search and quick sort, i will
figure out the code on my own (if i can) i just need to know what exactly
these methods entail.

thanks
patrick

 

Re:Index Search + Quick Sort


Quote
> please just explain the theory behind an index search and quick sort, i will
> figure out the code on my own (if i can) i just need to know what exactly
> these methods entail.

   "Index search"?  I presume you mean "indexed sequential": some method
is used to "index" (jump into) to a location of a database or file, from
where a sequential search then takes place.  A phone book is a good
illustration of this, since one visually "jumps" to a location and starts
to search sequentially after that.  Implied in this technique is that the
file is sorted, of course...
   Almost any programming book or text will show how the QuickSort works,
since it's one of the most commonly used algorithms in programming.  I
suggest you "search" <gg> your local libraries, where you surely will
find some useful information on this sort.

Re:Index Search + Quick Sort


In article <379971d...@news1.mweb.co.za>, patrick <bdinn...@mweb.co.za>
writes

Quote
>can someone please help...
>please just explain the theory behind quick sort, i will
>figure out the code on my own (if i can) i just need to know what exactly
>these methods entail.

Patrick - imagine you have a huge pile of stones. Pick a medium-sized
stone for reference purposes and then create two piles of stones, the
stones in the left pile being smaller than or equal to the reference
stone and the stones in the right pile being larger than the reference
stone.

Repeat the above operation on the left pile of stones and then on the
right pile of stones. Got four piles now? Good.

Repeat the operation on each of the four piles of stones... continue
until the piles are down to one stone each (some piles will get there
first).

Is this starting to make sense? Note that it's an obvious candidate for
a recursive solution!

That's how Quicksort works "logically". The "physical" details of
getting it to work in array-space are a little more subtle. Study any
standard text-book Quicksort algorithm to see how to handle this (but
keep the "piles of stones" analogy in mind - it helped me).

--
Marcus Morris
Ledbury, Herefordshire
Mar...@ntos.demon.co.uk

Other Threads