# Algorithms | Sorting | Question 11

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

## Recommended Posts:

- Algorithms | Sorting | Question 19
- Algorithms | Sorting | Question 14
- Algorithms | Sorting | Question 5
- Algorithms | Sorting | Question 6
- Algorithms | Sorting | Question 7
- Algorithms | Sorting | Question 13
- Algorithms | Sorting | Question 12
- Algorithms | Sorting | Question 23
- Algorithms | Sorting | Question 15
- Algorithms | Sorting | Question 23
- Algorithms | Sorting | Question 4
- Algorithms | Sorting | Question 23
- Algorithms | Sorting | Question 18
- Algorithms | Sorting | Question 23
- Algorithms | Sorting | Question 20