340 likes | 477 Views
An Adventure into Sorting. By Mauktik Gandhi Date: 12 th May 2002. Some Sorting Algorithms. Bubble Sort Insertion Sort Selection Sort Merge Sort Heap Sort Quick Sort (avg.). Well Established fact. Using comparison based sorting the fastest we can go is n*log (n)
E N D
An Adventure into Sorting By Mauktik Gandhi Date: 12th May 2002
Some Sorting Algorithms • Bubble Sort • Insertion Sort • Selection Sort • Merge Sort • Heap Sort • Quick Sort (avg.)
Well Established fact • Using comparison based sorting the fastest we can go is n*log (n) • So we are bound by a theorem established long ago.
Solution - Snip Snip • Well if it is not possible then whats the point trying. • So avoid comparison….
Possible, but need help • ASCII characters are already sorted for us • Why not use them as helpers ?? • So I did, I cheated
Steps taken to sort • Prepare the internal representation for taking the items to be sorted • Continue building representation as items are added one at a time. • Remove the items, one by one, amazingly they are sorted All take constant time !
That’s all, the first step is done. One node, the root of the amazing tree. Step 1.
Step 2. Adding Words Lets add “Car”
Lets add “Car” Adding “Car” C
Lets add “Car” Adding “Car” C A
Lets add “Lot” Completing “Car” C A R
Lets add “Lot” Adding “Lot” C L A R
Lets add “Lot” Adding “Lot” C L A O R
Lets add “Lot” Completing “Lot” C L A O R T
Adding “Cat” ?? Now add “Cat” C L A O R T
Adding “Cat” ?? Now add “a” C L A O R T
Adding “Cat” ?? That’s confusing C L A O R T T
Now add “Go” Where does “Go” go ?? C L G A O R T T
Now add “Go” Where does “Go” go ?? C L G A O O R T T
Now to Remove_First No end in sight C L G A O O R T T
My head is bursting Removing First C L C G A A O O R T T
Next Removing First C L G A O O T T
Next Removing First L G O O T
Continue Removing First L G O O T
I cant take it any longer Removing First L O T
Is it done ?? Well, its done
Testing • That showed how to sort four items • Similarly, a large number of words can be sorted • Question: Is it efficient ?
End Of Abstract Description WOW!! I survived the torture Hey, but what about efficiency??
Now lets talk Concrete • Completed first implementation for RESOLVE/C++ • The working class is Sorting_Machine_Kernel_X Sorting_Machine/Kernel_X.h Sorting_Machine/Kernel_X_Body.h
Number of words Time in Seconds Timing Comparison Table
I do a lot of work out here Processor taxing time !!
What’s Next ? • Templates, recursion and lots of procedure calls seem to eat on efficiency • So plan to re-implement it using C/C++ • Avoid recursion • More efficient memory management • Minimize procedure calls • Lastly implement and use exploration trees • Help avoid recursion • No need to decompose and recompose