Algorithm-quick sort


Algorithm QuickSort(data[],start,end)

 

1.low <- start

2.high <- end

3.elt <- data[low]

4.while(low < high)

a. while(data[low] <= elt && (low < high))

low <- low + 1

b. while(data[high] >= elt && (low < high))

high <- high - 1

c. if low < high then swap (data[low] , data[high])

5. swap( data [start] , data [high] )

6. Call Quicksort( data , start , high-1)

7. Call Quicksort( data, high+1 , end)

 

Explanation

 

      1. Pick one element in the array, which will be the pivot.

      2. Make one pass through the array, called a partition step, re-arranging the entries so that the pivot is in its proper place.

          • entries smaller than the pivot are to the left of the pivot.

          • entries larger than the pivot are to its right.

      3. Recursively apply quicksort to the part of the array that is to the left of the pivot,  and to the right part of the array.

      Here we don't have the merge step, at the end all the elements are in the proper order.


Sorting by MS.K.Abirami

  • BUBBLE SORT

    Bubble sort is a sorting algorithm that works by repeatedly stepping through lists that need to be sorted, comparing each pair of adjacent items and swapping them ...Read more »

  • INSERTION SORT

    A simple sorting technique that scans the sorted list, starting at the beginning, for the correct insertion point for each of the items from the unsorted list… Read more »

  • SELECTION SORT

    It starts by comparing the entire list for the lowest item and moves it to the #1 position. It then compares the rest of the list for the next-lowest item....Read more »

  • QUICK SORT

    A sorting technique that sequences a list by continuously dividing the list into two parts and moving the lower items to one side and the higher items to the other. … Read more »

  • BUBBLE SORT

    The number of comparison between elements and the number of exchange between elements determine the efficiency of Bubble Sort algorithm.Read more »

  • Insertion SORT

    Insertion sort is also a time taking technique as its complexity is O(n2)Read more »

  • selection SORT

    The number of comparison between elements and the number of exchange between elements determine the efficiency of Bubble Sort algorithm.Read more »

  • quick SORT

    The efficeieny of the quicksort depends on the pivot element. However the pivot element can also be choosen at random order or from the last element of the array

    Read more »