Insertion sort.
In
this method, sorting is done by inserting elements into an existing
sorted list. Initially, the sorted list has only one element. Other
elements are gradually added into the list in the proper position.
Merge Sort.
In
this method, the elements are divided into partitions until each
partition has sorted elements. Then, these partitions are merged and the
elements are properly positioned to get a fully sorted list.
Quick Sort.
In
this method, an element called pivot is identified and that element is
fixed in its place by moving all the elements less than that to its left
and all the elements greater than that to its right.
Radix Sort.
In
this method, sorting is done based on the place values of the number.
In this scheme, sorting is done on the less-significant digits first.
When all the numbers are sorted on a more significant digit, numbers
that have the same digit in that position but different digits in a
less-significant position are already sorted on the less-significant
position.
Heap Sort
In
this method, the file to be sorted is interpreted as a binary tree.
Array, which is a sequential representation of binary tree, is used to
implement the heap sort.
The
basic premise behind sorting an array is that its elements start out in
some random order and need to be arranged from lowest to highest.
It is easy to see that the list
1, 5, 6, 19, 23, 45, 67, 98, 124, 401
is sorted, whereas the list
4, 1, 90, 34, 100, 45, 23, 82, 11, 0, 600, 345
is
not. The property that makes the second one "not sorted" is that there
are adjacent elements that are out of order. The first item is greater
than the second instead of less, and likewise the third is greater than
the fourth and so on. Once this observation is made, it is not very hard
to devise a sort that proceeds by examining adjacent elements to see if
they are in order, and swapping them if they are not.
0 comments:
Post a Comment