Merge Sort Divide Conquer n n n Divide














- Slides: 14
Merge Sort Divide & Conquer n n n Divide into two halves Recursively sort the two Merge the two sorted lists A L G O R I T H M S 1
Merge Sort Divide & Conquer n n n Divide into two halves Recursively sort the two Merge the two sorted lists A L G O R I T H M S 2
Merge Sort Divide & Conquer n n n Divide into two halves Recursively sort the two Merge the two sorted lists A G L O R H I M S T 3
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A smallest L O R H I M S T auxiliary array 4
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A smallest L G O R H I M S T auxiliary array 5
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A L G smallest O H R H I M S T auxiliary array 6
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A L G smallest O H R I H I M S T auxiliary array 7
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A L G smallest O H R I H L I M S T auxiliary array 8
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A L G O H smallest R I H L M I M S T auxiliary array 9
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A L G O H smallest R I H L M I O M S T auxiliary array 10
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. smallest A G A L G O H smallest R I H L M I O M R S T auxiliary array 11
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. first half exhausted A G A L G O H R I smallest H L M I O M R S S T auxiliary array 12
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. first half exhausted A G A L G O H R I smallest H L M I O M R S S T T auxiliary array 13
Merge Sort Merge. n n n Keep track of smallest element in each sorted half. Insert smallest of two elements into auxiliary array. Repeat until done. first half exhausted A G A L G O H R I second half exhausted H L M I O M R S S T T auxiliary array 14