Introduction to Sorting

Sorting is a technique in which the data is put into some order or sequence. The data can be sorted in ascending order or in descending order. Normally sorting and searching are discussed together, when we have data in a sorted form then we can search for any entity in the data more easily. Suppose we have a database and in which there are records for example roll number of the students, name of the students, etc.

Each record that is going to be sorted will have a unique key on the basis of which searching will be done. Suppose we have record of employees in a database and we have the following data: employee ID, Name of the employee, Age of the employee and address of the employee. In this record we can take the id of the employee as the key to sort the records either in ascending or in descending order. When we need the information of employee 25 we simply search the employees with id 20 to 30.

Therefore, sorting makes it easier to search for a record.

Sorting Efficiency:

Sorting can be done in many different ways depending on the situation. We have two parameters on which the sorting will depend on: that are, the execution time of the program and the memory space needed by the program.

Types of Sorting Techniques:

The following are some of the techniques of sorting that are differentiated by the time they take and the memory space they require:

  1. Bubble Sort
  2. Insertion Sort
  3. Selection Sort
  4. Quick Sort
  5. Merge Sort
  6. Heap Sort