**Sorting:**

Fine, my quick typing on Algorithm, some quick points you can take down:

Dfn: it’s arranging a list of values into ascending or descending order.

Methods:

1. Bubble Sort Algorithm

This involves comparing adjacent pair of elements and swapping them if not sorted.

2. Selection sort

It works in such a way that:

· You find the smallest element and exchange it with the first element.

· Find the second smallest element in 2^{nd} position.

· Continue until the last position of the array to be sorted. This means that, for n elements, we will need n-1 passes.

3. **Insertion Sort**

It’s inserting of each element into its correct position in the sorted list.

Two lists can be used:

· Sorted list and

· Unsorted list

4. **Merge sort**

It involves divide and conquer sorting algorithm that divides the list into halves, sorts each half separately and then merges that sorted halves into sorted arrays.

5. Quick Sort

Use divide and conquer algorithm like merge sort.

Has two phases:

· Partition phase and

· Sort phase.

Divide the array into two partitions and then call quick sort function recurcively to sort the partitions.

The partition phase can show that the pivot is greater than all elements in one part(lower part) and then less than all in upper part.

Most works are done in the partition phase.

6. Shell Sort

1959 by Donald L. Shell.

Starts by comparing elements apart, then elements less far apart, and finally comparing elements far apart , and finally comparing adjacent elements (diminishing incremental sort).

Illustration:

· Arrange the data sequence into two dimensional arrays,

· Sort the columns of the array,

· The effects are that the data sequence is sorted out.

· Above process is repeated but each time with narrower array, that is , number of columns

## Leave a Reply