Open In App

Algorithms | Sorting | Question 11

Like Article
Like
Save
Share
Report

You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?

(A) Heap sort
(B) Merge sort
(C) Quick sort
(D) Insertion sort


Answer: (B)

Explanation: The data can be sorted using external sorting which uses merging technique. This can be done as follows:
1. Divide the data into 10 groups each of size 100.
2. Sort each group and write them to disk.
3. Load 10 items from each group into main memory.
4. Output the smallest item from the main memory to disk. Load the next item from the group whose item was chosen.
5. Loop step #4 until all items are not outputted.

The step 3-5 is called as merging technique.

Quiz of this Question


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads