The document discusses the merge sort algorithm. It uses a divide and conquer technique where the array is divided into sub-arrays which are then merged together to produce a sorted output array. The algorithm recursively splits the array in half until individual values remain, and then combines the sorted sub-arrays back together to form the fully sorted final array.
2. BASIC CONCEPT OF MERGE
SORT
I. Uses divide and conquer technique.
II. array is divided into sub-array.
III. Sub-arrays merged to get sorted result.
3. DIVIDE AND CONQUER
Divide and conquer method for algorithm
design:
• Divide: Large problem is divided into sub-problems
• Conquer: recursively solve the sub-problems
• Combine:
• Take the solutions to the sub-problems
• “merge” these solutions into final solution
3
28. SUMMARY OF SORTING
ALGORITHMS
Algorithm Time Notes
selection-sort O(n2) in-place
slow (good for small inputs)
insertion-sort O(n2) in-place slow (good for small
inputs)
quick-sort O(n log n)
expected
in-place, randomized fastest
(good for large inputs)
merge-sort O (n log n) sequential data access fast
(good for huge inputs)