Presentation is loading. Please wait.

Presentation is loading. Please wait.

Divide & Conquer n Divide into two halves n Recursively sort the two n Merge the two sorted lists 1 ALGORITHMS Merge Sort.

Similar presentations


Presentation on theme: "Divide & Conquer n Divide into two halves n Recursively sort the two n Merge the two sorted lists 1 ALGORITHMS Merge Sort."— Presentation transcript:

1 Divide & Conquer n Divide into two halves n Recursively sort the two n Merge the two sorted lists 1 ALGORITHMS Merge Sort

2 Divide & Conquer n Divide into two halves n Recursively sort the two n Merge the two sorted lists 2 ALGORITHMS Merge Sort

3 Divide & Conquer n Divide into two halves n Recursively sort the two n Merge the two sorted lists 3 AGLORHIMST Merge Sort

4 4 auxiliary array smallest AGLORHIMST Merge Sort Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. A

5 5 auxiliary array smallest AGLORHIMST A Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. G Merge Sort

6 6 auxiliary array smallest AGLORHIMST AG Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. H Merge Sort

7 7 auxiliary array smallest AGLORHIMST AGH Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. I Merge Sort

8 8 auxiliary array smallest AGLORHIMST AGHI Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. L Merge Sort

9 9 auxiliary array smallest AGLORHIMST AGHIL Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. M Merge Sort

10 10 auxiliary array smallest AGLORHIMST AGHILM Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. O Merge Sort

11 11 auxiliary array smallest AGLORHIMST AGHILMO Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. R Merge Sort

12 12 auxiliary array first half exhausted smallest AGLORHIMST AGHILMOR Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. S Merge Sort

13 13 auxiliary array first half exhausted smallest AGLORHIMST AGHILMORS Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. T Merge Sort

14 14 auxiliary array first half exhausted second half exhausted AGLORHIMST AGHILMORST Merge. n Keep track of smallest element in each sorted half. n Insert smallest of two elements into auxiliary array. n Repeat until done. Merge Sort


Download ppt "Divide & Conquer n Divide into two halves n Recursively sort the two n Merge the two sorted lists 1 ALGORITHMS Merge Sort."

Similar presentations


Ads by Google