150 likes | 180 Views
Learn about the Merge Sort algorithm, which follows the Divide and Conquer approach to sorting elements by dividing into two halves, recursively sorting them, and merging the sorted lists. Understand the step-by-step process of merging sorted elements.
E N D
A L G O R I T H M S Merge Sort • Divide & Conquer • Divide into two halves • Recursively sort the two • Merge the two sorted lists
A L G O R I T H M S Merge Sort • Divide & Conquer • Divide into two halves • Recursively sort the two • Merge the two sorted lists
A G L O R H I M S T Merge Sort • Divide & Conquer • Divide into two halves • Recursively sort the two • Merge the two sorted lists
A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. smallest smallest A auxiliary array
smallest smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. A G auxiliary array
smallest smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. A G H auxiliary array
smallest smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. A G H I auxiliary array
smallest smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. A G H I L auxiliary array
smallest smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. A G H I L M auxiliary array
smallest smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. A G H I L M O auxiliary array
smallest smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. A G H I L M O R auxiliary array
smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. first halfexhausted A G H I L M O R S auxiliary array
smallest A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. first halfexhausted A G H I L M O R S T auxiliary array
A G L O R H I M S T Merge Sort • Merge. • Keep track of smallest element in each sorted half. • Insert smallest of two elements into auxiliary array. • Repeat until done. first halfexhausted second halfexhausted A G H I L M O R S T auxiliary array