# Data Structure- Searching and Sorting Techniques Notes Class 12

## Searching and Sorting Techniques Notes

Sorting

Sorting means to arrange the data either in ascending order or descending order. It is the process of rearranging a sequence of objects so as to put them in some logical order.

Selection Sort :  Find the minimum element in unsorted array and swap it with the element in the begining  of the sorted array.

1. Selection sort algorithm is 60% more efficient than bubble sort algorithm.
2. Selection sort algorithm is easy to implement.
3. Selection sort algorithm can be used for small data sets, unfortunately Insertion sort algorithm best suitable for it.

1. Insertion sort algorithm is far better than selection sort algorithm.
2. Runtime of selection sort is algorithum is very poor

Bubble Sort : Bubble sort is a simple sorting algorithum. This sorting algorithum is compaison based algorithum is which each pair of adjacmt elements is compared and element are swapped if they  are not in order.

• Compare two adjoining values and exchange them, if they are not in proper order.
• After pass1, the largest element of the list will be at bottom.
• If we have array of n elements ,we have to do n-1 iterations before we get our sorted array

1. Bubble sort is one of the easiest sort algorithum
2. It is easy to implement
3. Elements are swapped in place, no use of extra array

1. Bubble sort algorithum is not suitable for large data sets
2. The code become complex for larger number of data

Insertion  Sort :

Insert an element from unsorted array to its correct position in sorted array . In Insertion sort, we assume the first element to be sorted.

1. Simple to code
2. Good performance with small list
3. Memory efficient 