Question 71
HardWhich sort is best when writes are very expensive (for example, on flash memory)?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
Which sort is best when writes are very expensive (for example, on flash memory)?
Merge sort
Selection sort or cycle sort, which minimise writes
Bubble sort
Insertion sort
Sign up free to see the answer and a step-by-step explanation.
What is the average number of swaps in bubble sort on a random permutation of n elements?
n(n − 1)/4
n log n
n²
n
Sign up free to see the answer and a step-by-step explanation.
Why is merge sort used for external sorting of huge files?
It needs no comparisons
It sorts in place
It merges sorted runs sequentially, which suits disks that are slow at random access
It uses recursion
Sign up free to see the answer and a step-by-step explanation.
How many passes does a k-way external merge sort need for N initial runs?
⌈log_k N⌉
N
N/k
k
Sign up free to see the answer and a step-by-step explanation.
What is a stable sort's key advantage when sorting by several keys?
It needs no comparisons
It is always faster
It uses less memory
You can sort by the secondary key first, then the primary key, and keep ties in the right order
Sign up free to see the answer and a step-by-step explanation.
Which sort works best on small arrays and is used inside hybrid sorts?
Merge sort
Insertion sort
Heap sort
Shell sort only
Sign up free to see the answer and a step-by-step explanation.
What is the worst-case time of Shell sort with Hibbard's gaps (2ᵏ − 1)?
O(n^1.5)
O(n)
O(n log n)
O(n²)
Sign up free to see the answer and a step-by-step explanation.
Bucket sort on n uniformly distributed floats in [0, 1) with n buckets has what expected time?
O(n log n)
O(n²)
O(log n)
O(n)
Sign up free to see the answer and a step-by-step explanation.
What does a sorting network's 'depth' measure?
The number of elements
The memory used
The number of parallel comparison steps needed
The number of swaps in the worst case
Sign up free to see the answer and a step-by-step explanation.
Which statement about quick sort's space usage is true?
It needs O(n log n) space
It needs no stack
It needs O(n) extra arrays
It is in place but needs O(log n) stack on average (O(n) worst case without care)
Sign up free to see the answer and a step-by-step explanation.