Quicksort and Divide-and-Conquer Flashcards
(5 cards)
What is the divide-and-conquer strategy?
Divide the problem into subproblems, solve them recursively, and combine their results.
How does Quicksort work?
Chooses a pivot, partitions the array into elements less than and greater than the pivot, and recursively sorts them.
What are the time complexities of Quicksort?
Best/average case: O(n log n), worst case: O(n²).
In-place, but not stable.
When does Quicksort perform poorly?
When the pivot is consistently the smallest or largest element—e.g., sorted input with poor pivot choice.
What is tail recursion and how is it relevant to Quicksort?
Tail recursion occurs when the recursive call is the last operation in a function—used in Quicksort optimizations.