11 - Comparision of merge and quick sort

Click here to load reader

  • date post

    03-Apr-2015
  • Category

    Documents

  • view

    44
  • download

    1

Embed Size (px)

Transcript of 11 - Comparision of merge and quick sort

1/22/2011 11:28:05 AM

AIIS

1

OUTLINEIntroduction Algorithm for merge sort Example Quick Sort Algorithm For Quick Sort Example

1/22/2011 11:28:05 AM

AIIS

2

What Is Meant By Merge Sort ?Merge sort is northing but the given array is divided into two parts. i) LEFT Part ii) RIGHT Part Both the left part and the right part should be in sorted recursively. Latter the sorted left part and the sorted right part are finally merged in to a single sorted array.

1/22/2011 11:28:05 AM

AIIS

3

y

The process of merging of two sorted vectors into a single sorted vector is called as simple merging. The only condition in merge sort is that the both vectors should be sorted either in Ascending order (or) Descending order.

y

1/22/2011 11:28:05 AM

AIIS

4

Algorithm For MERGE SortMerge sort (a, low, high) { if (low < high) { mid = (low+high)/2; merge sort(a,low,mid); merge sort(a,mid+1,high); simple merge(a,low,mid,high); } }1/22/2011 11:28:05 AM AIIS 5

simple merge(a,low,mid,high) { while(i