Comparison-Based Sorting
- 50Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the basic task of sorting an array of n items when a consistent ordering is available?
What is the basic task of sorting an array of n items when a consistent ordering is available?
50 questions
- 1
What is the basic task of sorting an array of n items when a consistent ordering is available?
- A
Compare every pair and return only the pair with the greatest difference
- B
Remove duplicate items and return the remaining items in their original order
- C
Group items by memory location without changing their relative values
- D
Rearrange all n items from least to greatest according to that ordering
Correct answer
DRearrange all n items from least to greatest according to that ordering
Explanation
Sorting rearranges the input items according to the available ordering; the described goal is an array containing all n items from least to greatest.
- A
- 2
Why does comparison-based sorting require a consistent way to compare the items?
- A
The algorithm needs comparisons to determine each item's memory address
- B
The algorithm needs comparisons to determine the items' relative ordering
- C
The algorithm needs comparisons to ensure every item has a unique value
- D
The algorithm needs comparisons to decide how many items to remove
Correct answer
BThe algorithm needs comparisons to determine the items' relative ordering
Explanation
A comparison-based sort uses relations such as less than and greater than to determine where items belong in the sorted output.
- A
- 3
What does it mean for a sorting algorithm to be stable?
- A
The algorithm always uses the same number of comparisons on every input
- B
Items with unequal values retain their relative order from before the sort
- C
The algorithm produces the same output regardless of the comparison rule
- D
Items with equal values retain their relative order from before the sort
Correct answer
DItems with equal values retain their relative order from before the sort
Explanation
Stability preserves the original relative order of items whose sort keys are equal.
- A
- 4
A spreadsheet is sorted by last name after it was already sorted by first name. What does stability ensure for people with the same last name?
- A
They are moved to the beginning of the spreadsheet
- B
They retain their original positions regardless of their last names
- C
They are reordered alphabetically by their first names automatically
- D
They remain in their previous first-name order
Correct answer
DThey remain in their previous first-name order
Explanation
A stable sort preserves the prior relative ordering of tied items, so people sharing a last name remain in their earlier first-name order.
- A
- 5
Which statement about the direction of sorting is supported by the material?
- A
Sorting can use either ascending or descending order, though ascending is the focus
- B
Sorting must use ascending order because comparisons cannot support descending order
- C
Sorting must alternate between ascending and descending order on each pass
- D
Sorting can use descending order only when the items are all distinct
Correct answer
ASorting can use either ascending or descending order, though ascending is the focus
Explanation
The stated task focuses on least-to-greatest order, but the material notes that greatest-to-least sorting is also possible.
- A
- 6
How does insertion sort place an item while processing an array?
- A
It repeatedly swaps adjacent items until the entire array has been scanned without a swap
- B
It partitions the array around a pivot and recursively sorts both resulting regions
- C
It compares the item with earlier items and shifts larger items right until the insertion position is found
- D
It finds the smallest item in the entire remaining array and swaps it into the next position
Correct answer
CIt compares the item with earlier items and shifts larger items right until the insertion position is found
Explanation
Insertion sort examines the items before the current item, shifting larger items to the right to make space for the item being inserted.
- A
- 7
Why is insertion sort stable when implemented as described?
- A
It avoids comparing items that have equal values
- B
It stores equal-valued items in a separate auxiliary array
- C
It always moves every equal-valued item to the start of the array
- D
Equal-valued items can retain their relative order as later items are inserted
Correct answer
DEqual-valued items can retain their relative order as later items are inserted
Explanation
Insertion sort can preserve the relative order of equal items by inserting items without moving them past earlier equal items.
- A
- 8
What does it mean that insertion sort can be performed in-place?
- A
It stores only the minimum item and discards the rest during sorting
- B
It rearranges items within the input array without requiring extra storage for another array
- C
It sorts the array without comparing any items
- D
It keeps the input array unchanged and writes the result to a new array
Correct answer
BIt rearranges items within the input array without requiring extra storage for another array
Explanation
In-place sorting uses the input array itself for rearrangement rather than requiring an additional array to hold the result.
- A
- 9
What is insertion sort's stated asymptotic performance category?
- A
O(N2)
- B
O(N)
- C
O(logN)
- D
O(NlogN)
Correct answer
AO(N2)
Explanation
The material characterizes insertion sort as O(N2), which becomes costly for large inputs.
- A
- 10
What does selection sort do at each position in its sorted prefix?
- A
It finds the minimum among the unsorted items, including the current position, and swaps it into place
- B
It finds the maximum among the sorted items and moves it to the current position
- C
It compares the current item only with its immediate neighbor and swaps if needed
- D
It chooses a pivot and places all smaller items on one side of it
Correct answer
AIt finds the minimum among the unsorted items, including the current position, and swaps it into place
Explanation
Selection sort finds the minimum of the unsorted portion starting at the current position and swaps that minimum into the position.
- A
- 11
After selection sort places the first minimum at index 0, which portion can it ignore in later passes?
- A
Every index after 0, because the remaining items are already ordered
- B
Index 0, because that position is already sorted
- C
No indices, because selection sort must reconsider every earlier position
- D
Only the final index, because it contains the next minimum
Correct answer
BIndex 0, because that position is already sorted
Explanation
Each pass fixes the next position in the sorted prefix. Once index 0 is correctly filled, it need not be considered again.
- A
- 12
How can selection sort preserve the order of equal-valued items, according to the material?
- A
By copying all equal-valued items into an auxiliary array
- B
By comparing only items that have different values
- C
By shifting items carefully rather than relying on a potentially order-changing swap
- D
By selecting the maximum instead of the minimum on every pass
Correct answer
CBy shifting items carefully rather than relying on a potentially order-changing swap
Explanation
Although a basic swapping implementation may disrupt ties, selection sort can be made stable by shifting items in a suitable way.
- A
- 13
Which operation is central to bubble sort's repeated passes?
- A
Compare adjacent unsorted items and swap them when they are out of order
- B
Split the array in half and merge the sorted halves
- C
Remove the maximum item from a heap and place it at the array's end
- D
Find the minimum item in the entire unsorted region and swap it into place
Correct answer
ACompare adjacent unsorted items and swap them when they are out of order
Explanation
Bubble sort scans through adjacent unsorted pairs, swapping pairs that are out of order.
- A
- 14
What happens to a large item during a bubble-sort pass, as described in the material?
- A
It becomes the pivot and divides the array into two recursive regions
- B
It tends to move toward the far-right indices through successive swaps
- C
It moves toward the far-left index by avoiding adjacent swaps
- D
It is immediately copied to a separate array and removed from the input
Correct answer
BIt tends to move toward the far-right indices through successive swaps
Explanation
Successive adjacent swaps move large items toward the right end of the array, where they reach their sorted positions.
- A
- 15
When can bubble sort stop early?
- A
After a full pass makes no swaps, indicating that no adjacent items were out of order
- B
As soon as it finds one pair of items that is already in order
- C
After the smallest item reaches the first index, regardless of the remaining items
- D
After it completes its first pass, regardless of whether it made swaps
Correct answer
AAfter a full pass makes no swaps, indicating that no adjacent items were out of order
Explanation
If a complete pass makes no swaps, the array is already sorted and bubble sort can terminate.
- A
- 16
Which statement correctly describes bubble sort's stability, memory use, and best-case input?
- A
It is unstable and requires an auxiliary array, and it performs best on reverse-sorted input
- B
It is stable and in-place, and it performs best when the array is nearly sorted
- C
It is stable but requires an auxiliary array, and it performs best on random input
- D
It is unstable but in-place, and it performs best when all values are distinct
Correct answer
BIt is stable and in-place, and it performs best when the array is nearly sorted
Explanation
Bubble sort is described as stable and in-place, with its best performance occurring when the array is already nearly sorted.
- A
- 17
What is the basic divide-and-conquer idea used by merge sort?
- A
Recursively split the array into smaller portions, then merge the sorted portions
- B
Choose one pivot and place every item on one side or the other
- C
Repeatedly select the minimum item and swap it into the next position
- D
Build a heap and repeatedly remove its maximum item
Correct answer
ARecursively split the array into smaller portions, then merge the sorted portions
Explanation
Merge sort divides the array recursively and combines the resulting sorted portions during the return from recursion.
- A
- 18
Why can a one-item array serve as a base case for merge sort?
- A
A single item requires no comparisons with items in the other half
- B
A single item must be moved to the end of the array before merging
- C
A single item cannot be out of order with any other item in that array
- D
A single item is always the minimum value in the original input
Correct answer
CA single item cannot be out of order with any other item in that array
Explanation
A one-item array is already sorted because there is no second item with which it could be out of order.
- A
- 19
When merging two sorted arrays, which items need to be compared next?
- A
The last item in each array, moving backward toward the beginning
- B
Every remaining item in one array against every remaining item in the other
- C
The first unmerged item from each array
- D
The middle item of each array, regardless of what has already been merged
Correct answer
CThe first unmerged item from each array
Explanation
Because each input portion is sorted, its first unmerged item is its smallest remaining item. Comparing the two such items identifies the next item to place.
- A
- 20
Why can merging two sorted portions take O(N) time in total?
- A
Each item is compared with every other item before it is copied
- B
The merge operation recursively sorts every pair again from scratch
- C
The merge operation repeatedly searches the whole result for its next minimum
- D
Each step compares the leading remaining items and moves one item into the merged result
Correct answer
DEach step compares the leading remaining items and moves one item into the merged result
Explanation
A merge advances through the two portions, comparing their current leading items and moving items into the result, so the total work is linear in the number of items being merged.
- A
- 21
What tie-handling choice allows merge sort to preserve stability?
- A
Avoid merging equal-key items until all unequal items have been placed
- B
Always take the equal-key item from the right portion before the left portion
- C
When equal keys are encountered, take them in an order that preserves their original relative order
- D
Move all equal-key items to the end of each merged portion
Correct answer
CWhen equal keys are encountered, take them in an order that preserves their original relative order
Explanation
To remain stable, merge sort must handle ties so that equal-key items retain the same relative order they had before the sort.
- A
- 22
Which statement describes the usual implementation trade-off for merge sort?
- A
It is simplest in-place, while copying portions makes stability impossible
- B
It is simplest when portions are copied and merged into an output array; an in-place version is more complicated
- C
It can be made stable only by avoiding recursion
- D
It requires no merging when implemented with an auxiliary array
Correct answer
BIt is simplest when portions are copied and merged into an output array; an in-place version is more complicated
Explanation
The material says merge sort is easiest to implement by copying portions and merging them into an array; an in-place version is possible but more complicated.
- A
- 23
Which combination of performance and parallelization is associated with merge sort?
- A
It runs in O(N2) time and cannot process separate portions independently
- B
It runs in O(logN) time and parallelizes only its final merge
- C
It runs in O(NlogN) time and can sort separate portions in parallel
- D
It runs in O(N) time and must sort the entire array in one sequential pass
Correct answer
CIt runs in O(NlogN) time and can sort separate portions in parallel
Explanation
Merge sort has O(NlogN) performance and is readily parallelized because separate portions can be processed independently.
- A
- 24
How does heapsort use a max-heap to build the sorted array?
- A
Repeatedly remove the maximum and place it at the array's end
- B
Compare every pair and swap them whenever their values differ
- C
Partition the array around the heap's root and recursively sort both sides
- D
Repeatedly remove the minimum and place it at the array's beginning
Correct answer
ARepeatedly remove the maximum and place it at the array's end
Explanation
With a max-heap, the maximum can be extracted and placed at the end of the portion still considered part of the heap.
- A
- 25
What happens to the heap region as heapsort places maxima into their final positions?
- A
It is split into two separate heaps after every extraction
- B
It remains the full array, because placed maxima must be reconsidered
- C
It becomes smaller, because each extracted maximum is excluded from later heap operations
- D
It becomes larger, because each extracted maximum is added back to the heap
Correct answer
CIt becomes smaller, because each extracted maximum is excluded from later heap operations
Explanation
Once an extracted maximum is placed at the end, that location is no longer part of the heap, so the active heap shrinks.
- A
- 26
Why is heapsort not stable?
- A
The algorithm uses an auxiliary array that overwrites the original tie order
- B
Heap operations do not guarantee that equal-valued items preserve their original relative order
- C
The algorithm removes equal-valued items before sorting them
- D
Heap operations always reverse the order of equal-valued items
Correct answer
BHeap operations do not guarantee that equal-valued items preserve their original relative order
Explanation
A heap does not provide a guarantee that equal-valued items will retain their initial relative order through its operations.
- A
- 27
Why can heapsort be performed in-place?
- A
The algorithm uses no comparisons and therefore needs no storage
- B
The algorithm sorts only the values and leaves the array positions unchanged
- C
A heap stores all values in a separate linked structure that is discarded after sorting
- D
The heap can be represented in the array, and extracted maxima can be placed at the array's end
Correct answer
DThe heap can be represented in the array, and extracted maxima can be placed at the array's end
Explanation
The heap is represented within the array, and each maximum can be placed in its final end position as the heap shrinks.
- A
- 28
Why does heapsort have worst-case performance of O(NlogN) in the described approach?
- A
It performs N full scans, each requiring O(N) comparisons
- B
It performs N merges, each requiring O(1) work
- C
It performs N maximum extractions, each requiring O(logN) heap work
- D
It performs logN extractions, each requiring O(N) comparisons
Correct answer
CIt performs N maximum extractions, each requiring O(logN) heap work
Explanation
The described method chooses the maximum N times; maintaining the heap after an extraction takes logarithmic time, yielding O(NlogN) overall.
- A
- 29
What is the purpose of choosing a pivot in quicksort?
- A
To partition the data so lower values go to one side and higher values to the other
- B
To ensure that all equal-valued items keep their original positions
- C
To merge two previously sorted halves into a single sorted array
- D
To identify the minimum value in the entire array without comparisons
Correct answer
ATo partition the data so lower values go to one side and higher values to the other
Explanation
Quicksort partitions around a pivot, placing lower values on one side and higher values on the other before recursively sorting those regions.
- A
- 30
What happens to a quicksort pivot after its partitioning step is completed?
- A
It occupies its final sorted position and can be excluded from recursive calls
- B
It is moved to the start of the array and compared again in every recursive call
- C
It is discarded because only the two partitions are needed in the final output
- D
It is copied into a new array and merged with the recursively sorted regions
Correct answer
AIt occupies its final sorted position and can be excluded from recursive calls
Explanation
After partitioning, the pivot is in its final location; recursive calls sort the values on either side without needing to include the pivot.
- A
- 31
How can quicksort operate in-place, according to the material?
- A
It uses no recursive calls and stores each item in a separate list
- B
It keeps the array unchanged while storing all sorted values in a heap
- C
It copies each partition into a new array and merges them after recursion
- D
It modifies items within index ranges of the input array without requiring a merge step
Correct answer
DIt modifies items within index ranges of the input array without requiring a merge step
Explanation
An in-place implementation recursively processes index ranges in the original array and does not need a merge step to combine results.
- A
- 32
Why is quicksort not stable as described?
- A
Its pivot is always the smallest item and removes all ties
- B
It copies values into an output array in reverse order
- C
Partitioning can move equal-valued items past one another, changing their relative order
- D
It stops before placing equal-valued items into the same partition
Correct answer
CPartitioning can move equal-valued items past one another, changing their relative order
Explanation
The rearrangements used during partitioning do not necessarily preserve the relative order of equal-valued items.
- A
- 33
What input and pivot choices can lead to quicksort's O(N2) worst case?
- A
An array of equal-sized partitions combined with a balanced recursion tree
- B
A randomly ordered array combined with repeatedly choosing a central pivot
- C
A sorted array combined with repeatedly choosing an extreme pivot, such as the minimum
- D
A sorted array combined with repeatedly choosing a central pivot
Correct answer
CA sorted array combined with repeatedly choosing an extreme pivot, such as the minimum
Explanation
If each pivot is the minimum in an already sorted array, one partition is empty and the other contains nearly all remaining items, producing highly unbalanced recursion.
- A
- 34
Which statement best characterizes quicksort's average and practical performance in the material?
- A
Its average is O(NlogN), and random pivots often make it faster in practice than other O(NlogN) sorts
- B
Its average is O(N2), but its worst case is O(NlogN)
- C
Its average is O(logN), but it is slower in practice than quadratic sorts
- D
Its average and worst case are both O(N) when pivots are chosen randomly
Correct answer
AIts average is O(NlogN), and random pivots often make it faster in practice than other O(NlogN) sorts
Explanation
Quicksort has average O(NlogN) behavior and is described as often being practically faster than other algorithms in that category when pivots are selected randomly.
- A
- 35
Why can insertion sort become impractical as the input grows, despite being quick on a few thousand items?
- A
Its O(N2) growth makes work rise much more rapidly than the input size
- B
Its time stays constant while its memory use grows exponentially
- C
Its O(logN) growth makes it unsuitable only for very small arrays
- D
Its O(NlogN) growth makes it slower than every linear-time algorithm
Correct answer
AIts O(N2) growth makes work rise much more rapidly than the input size
Explanation
The material contrasts insertion sort's quick behavior on a few thousand items with potentially very long runtimes for much larger inputs, reflecting its O(N2) growth.
- A
- 36
Which comparison captures the material's scale-up discussion for merge sort?
- A
It is described as taking weeks for millions of items and seconds for billions on a home computer
- B
It is described as effectively quick up to millions of items, with billions potentially taking minutes on a home computer
- C
It is described as having the same scaling behavior as insertion sort for all input sizes
- D
It is described as taking hours for millions of items and years for billions on a home computer
Correct answer
BIt is described as effectively quick up to millions of items, with billions potentially taking minutes on a home computer
Explanation
The material presents merge sort's O(NlogN) growth as fast up to millions of items, while sorting billions may take minutes on a home computer.
- A
- 37
What practical performance contrast is stated between quicksort and merge sort for very large inputs?
- A
Quicksort is described as taking hours for millions, while merge sort takes weeks for thousands
- B
Quicksort is described as always faster by an exact fixed factor for every input size
- C
Quicksort is described as taking years for billions, while merge sort takes seconds
- D
Quicksort may sort billions of items in minutes, while merge sort is also described as taking minutes for billions on a home computer
Correct answer
DQuicksort may sort billions of items in minutes, while merge sort is also described as taking minutes for billions on a home computer
Explanation
The material says quicksort can be in the minutes category even for billions of items, and gives a minutes-scale estimate for merge sort on billions of items on a home computer.
- A
- 38
Why should algorithm selection consider more than the worst-case bound alone?
- A
Worst-case behavior is important, but average behavior and practical performance can also affect which algorithm suits a task
- B
Average behavior makes worst-case guarantees unnecessary for every application
- C
Worst-case behavior always predicts the exact runtime on every input
- D
Practical performance is determined only by whether an algorithm is stable
Correct answer
AWorst-case behavior is important, but average behavior and practical performance can also affect which algorithm suits a task
Explanation
The material notes that worst-case bounds are important but may not be the most informative consideration in every situation; average and practical performance also matter.
- A
- 39
What broader lesson follows from the runtime comparisons among sorting algorithms?
- A
All sorting algorithms take essentially the same time once the input has more than a thousand items
- B
The number of items affects memory use but not sorting time
- C
Choosing an algorithm appropriate to the input scale can greatly affect how long sorting takes
- D
Stability alone determines whether an algorithm can sort large inputs efficiently
Correct answer
CChoosing an algorithm appropriate to the input scale can greatly affect how long sorting takes
Explanation
The examples contrast how different complexity categories scale, showing why choosing an appropriate sorting algorithm matters substantially.
- A
- 40
In a decision-tree analysis of comparison-based sorting, what does a node represent?
- A
A sorted subarray that must be copied into the final result
- B
A single input item together with its original array index
- C
A complete sequence of swaps that has already sorted the input
- D
A set of orderings still possible given the comparisons made so far
Correct answer
DA set of orderings still possible given the comparisons made so far
Explanation
A decision-tree node represents the possible orderings consistent with the comparison outcomes encountered along the path to that node.
- A
- 41
What does each comparison correspond to in a comparison-sorting decision tree?
- A
A merge operation that combines all possible permutations at once
- B
A leaf that records the final sorted array before any recursion
- C
A decision with possible outcome branches that narrows the remaining orderings
- D
A node that guarantees the input is sorted regardless of the outcome
Correct answer
CA decision with possible outcome branches that narrows the remaining orderings
Explanation
Comparisons distinguish possible relative orderings; their outcomes determine which branch of the decision tree is followed.
- A
- 42
What does a root-to-leaf path in the decision tree represent?
- A
A list of all permutations that the algorithm can produce at once
- B
The memory locations used by the algorithm during one merge operation
- C
The sequence of input items before any comparisons are made
- D
A possible run of the sorting algorithm under a particular sequence of comparison outcomes
Correct answer
DA possible run of the sorting algorithm under a particular sequence of comparison outcomes
Explanation
For a particular input ordering, the comparison outcomes determine a path from the root to a leaf, corresponding to that run of the algorithm.
- A
- 43
Why must a comparison-sorting decision tree have at least N! leaves for N distinct items?
- A
There are only N! possible comparison outcomes for the entire algorithm
- B
Every comparison creates N! new branches in the tree
- C
Each item requires exactly N! comparisons before it can be placed
- D
It must distinguish all N! possible input orderings to determine their correct sorted order
Correct answer
DIt must distinguish all N! possible input orderings to determine their correct sorted order
Explanation
There are N! possible permutations of N distinct items, and a correct comparison sort must be able to distinguish the orderings that require different outputs.
- A
- 44
What does the decision-tree leaf-count argument imply about the worst-case number of comparisons?
- A
A decision tree with at least N! leaves requires exactly N comparisons on every path
- B
A binary decision tree with at least N! leaves must have height at most log2(N!)
- C
A binary decision tree with at least N! leaves must have height at least log2(N!)
- D
A decision tree with at least N! leaves requires no comparisons when the input is sorted
Correct answer
CA binary decision tree with at least N! leaves must have height at least log2(N!)
Explanation
A binary tree of height h has at most 2h leaves, so accommodating at least N! leaves requires h≥log2(N!).
- A
- 45
How can log(N!) be rewritten using logarithm rules?
- A
As the difference logN−log(N−1)
- B
As N times the sum 1+2+⋯+N
- C
As the sum log1+log2+⋯+logN
- D
As the product log1⋅log2⋯logN
Correct answer
CAs the sum log1+log2+⋯+logN
Explanation
Since N!=1⋅2⋯N, the logarithm of the product is the sum of the logarithms of its factors.
- A
- 46
Why does the sum log1+⋯+logN have a lower bound on the order of NlogN?
- A
Every term equals logN, so the sum is exactly NlogN
- B
At least about half the terms are at least log(N/2), giving a sum on the order of NlogN
- C
Only the term log1 contributes to the sum's asymptotic growth
- D
The terms decrease as the index increases, so their sum is at most logN
Correct answer
BAt least about half the terms are at least log(N/2), giving a sum on the order of NlogN
Explanation
For indices from roughly N/2 through N, there are on the order of N terms, each at least log(N/2). Their sum is therefore Ω(NlogN).
- A
- 47
What lower bound follows for the worst-case running time of comparison-based sorting?
- A
Ω(N2)
- B
Ω(logN)
- C
Ω(N)
- D
Ω(NlogN)
Correct answer
DΩ(NlogN)
Explanation
The decision-tree argument shows that the tree height, and thus the worst-case comparison count, is at least log(N!)=Ω(NlogN).
- A
- 48
What does the comparison-sorting lower bound imply about designing a faster comparison-based sorting algorithm?
- A
Every comparison-based sorting algorithm must be stable to achieve O(NlogN) time
- B
A comparison-based sort can achieve constant time by choosing a suitable pivot
- C
No comparison-based sorting algorithm can have worst-case asymptotic time better than Ω(NlogN)
- D
Every comparison-based sorting algorithm must take Θ(N2) time
Correct answer
CNo comparison-based sorting algorithm can have worst-case asymptotic time better than Ω(NlogN)
Explanation
The lower bound applies to every comparison-based sorting algorithm, so no such algorithm can improve the worst-case asymptotic lower bound beyond Ω(NlogN).
- A
- 49
Why can sorting without comparisons potentially avoid the comparison-based lower bound?
- A
Sorting without comparisons eliminates the need to arrange items in any order
- B
The decision-tree proof assumes that all sorting algorithms use heaps
- C
The decision-tree proof applies specifically to algorithms whose ordering decisions come from comparisons
- D
Sorting without comparisons guarantees linear time for every possible input
Correct answer
CThe decision-tree proof applies specifically to algorithms whose ordering decisions come from comparisons
Explanation
The lower-bound argument is for comparison-based sorting; algorithms that do not rely on comparisons fall outside the argument's scope and may use a different approach.
- A
- 50
Which statement summarizes the trade-offs identified for efficient comparison-based sorts?
- A
Every O(NlogN) sort is both stable and in-place by definition
- B
Only stable algorithms can sort in O(NlogN) time
- C
They can achieve O(NlogN) behavior, but stability and in-place operation are separate features that do not always come together
- D
Comparison-based sorts can achieve O(N) worst-case time if they use no extra memory
Correct answer
CThey can achieve O(NlogN) behavior, but stability and in-place operation are separate features that do not always come together
Explanation
The material notes that some sorts are stable and some can be in-place, but the best-performing algorithms do not necessarily combine both features; O(NlogN) is the efficient comparison-sort category discussed.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.