Question: The merge-sort algorithm for sorting a list is based on dividing the list into smaller lists, then sorting each smaller list and finally merging these
The merge-sort algorithm for sorting a list is based on dividing the list into smaller lists, then
sorting each smaller list and finally merging these sorted smaller lists into one resulting list.
Accordingly, to sort list L:
- Divide L into two lists L1 and L2 of approximately equal length
- Sort L1 and L2 (using merge-sort) giving S1 and S2 respectively
- Merge S1 and S2 giving the sorted list R.
Write a PROLOG implementation of merge-sort.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
