eguruchela

What is sorting and methods of sorting


Answer:

Sorting means ordering the data in an increasing or decreasing order as per linear relationship among the data items.

The sorting can be done on stings (names, address, city etc.), numbers and records.

There is many methods for sorting, few common sorting methods are as follows:

Insertion sort

The sorting is done by inserting elements into an existing sorted list. Initially, the sorted list has only one element.

After that other elements are gradually added into the list in the proper position.

Merge Sort

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

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

The sorting is done based on the place values of the number. In this method, 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

The file to be sorted is interpreted as a binary tree. Array 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.

Bubble sort

It compares last element with the preceding element. If the last element is less than that of preceding element swapping takes place.

Then the preceding element is compared with that previous element.

👈       👉