Data Sorting
Sorting data:
Sorting is when working with data arranged according to their ascending or descending data of the same category may need to be sorted. Data can be sorted in two ways according to their value.
There are various algorithms or methods of sorting, viz
(i) Insertion Sort
(ii) Replacement Sort
(iii) Quick Sort
(iv) Bubble Sort
(V) Sell Sort
(vi) Selection Sort
(vi) Binary Tree Sort
(viii) Tournament Sort
(ix) Heap Sort
(x) Address Count Sort
(xi) Merge Sort
(xii) Radix Sort etc.
Bubble Sort:
The most commonly used sorting method is the bubble sort method. Usually this method is used when the number of data is large. Sorting takes less time if the data is well organized. The bubble sort method involves pairwise comparisons. The algorithm of bubble sort is as follows:
Bubble Sort Algorithm:
Step-1: Sorting is done by comparing the first and second numbers of the array.
Step-2: Then the 2nd and 3rd numbers are compared and arranged.
Step-3: In this way the process continues till the last data.
Step-4: If complete data is not arranged in first level (label) then another level (label) has to be started.
Step-5: Follow steps 1 to 3 at the new level.
Step-6. If complete data is not sorted at this level then another level should be started and processing should be done by following steps 1 to 3.
Step-7 : Maximum level number will be 1 less than the amount of data. And each level will decrease by one operation. That is, if there is N number of data, the number of layers is N-1 and each layer has to be operated by N-1, N-2, N-3...
Comparative advantages and disadvantages of different sorting methods:
(i) Selection sort method is generally more useful for sorting small amount of data. For most arrays this method takes less time. Sorting random data takes relatively long time.
(ii) The simplest sorting method is the selection sort method.
(iii) Replacement sorting is a hierarchical sorting but replacement sorting method is relatively more useful for sorting random data.
(iv) Quick sort method is more useful for sorting large amount of data.
(v) Insertion sort is generally more useful for sorting small amount of data. But many times to place any data in a specific position, all the data in the array needs to be changed, which takes more time.
Comments
Post a Comment