ADA: Sorting - Concept of Merging

Concept of Merging

Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the two sorted halves. The merge() function is used for merging two halves. The merge(arr, l, m, r) is key process that assumes that arr[l..m] and arr[m+1..r] are sorted and merges the two sorted sub-arrays into one. 

Problem Statement:

Consider two pile of cards. Each pile is stored and placed face up on a table with the smallest card on top. We will merge these into a single sorted pile faced down on the table.
Output

No comments:

Powered by Blogger.