Advanced Sorting. We discussed simple sorting earlier . The sorts described there bubble, Selection and insertion sorts easy to implement but are slow. Now we look at faster sorts. This week we cover two advanced approaches to sorting: Shellsort and quicksort.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
We discussed simple sorting earlier . The sorts described there
and insertion sorts
easy to implement but are slow.
Now we look at faster sorts
Here's the problem with the insertion sort.
the algorithm shifts over
one cell and sorts 1, 5, and 9.
all the elements have been
4-sorted, which means that
all items spaced 4 cells apart
are sorted among themselves.
After the complete 4-sort, the array can be thought of as comprising four subarrays:
(0,4,8), (1,5,9), (2,6), and (3,7), each of which is completely sorted. These subarrays are
interleaved, but otherwise independent.
The spacing between elements for these sorts is called the increment and is traditionally represented by the letter h
h = (h–1) / 3