What is Quick Sort? - Answers divide-and-conquer sorting algorithm that sorts elements by selecting a
"pivot" and partitioning the array into elements less than and greater than the pivot.
What is the average time complexity of Quick Sort for random input? - Answers O(n log n) QS
What is the worst-case time complexity of Quick Sort for random input? - Answers O(n^2) QS
What is the best-case time complexity of Quick Sort for random input? - Answers O(n log n) QS
How does Quick Sort choose a pivot? - Answers various ways: first element, last element, random
element
What are the steps of the Quick Sort algorithm? - Answers Choose a pivot.
Partition the array into elements less than and greater than the pivot.
Recursively apply Quick Sort to the subarrays.
partitioning process in Quick Sort - Answers Recursion in Quick Sort allows the algorithm to sort the
smaller subarrays created by the partitioning process until the base case (array of size 0 or 1) is reached.
common use case for Quick Sort - Answers sorting large datasets due to its average-case efficiency and
good cache performance.
Three functions required for quicksort - Answers swap, partition and quicksort
Insertion Sort - Answers sorting algorithm that builds a sorted array one element at a time by inserting
elements from the unsorted portion into the correct position in the sorted portion.
best-case time complexity of Insertion Sort - Answers O(n) (when the array is already sorted). IS
average and worst-case time complexity of Insertion Sort - Answers O(n²) (for random order and reverse
order respectively) IS
basic steps of Insertion Sort - Answers Start from the second element.
Compare it with elements in the sorted portion (to its left).
Shift larger elements to the right.
Insert the current element in its correct position.
Repeat until the array is sorted.
, some common use cases for Insertion Sort - Answers Efficient for small data sets and as a part of more
complex algorithms like Hybrid Sorts.
Merge Sort - Answers divide-and-conquer sorting algorithm that recursively splits an array into halves,
sorts each half, and merges the sorted halves back together.
time complexity of Merge Sort - Answers O(nlogn)
basic steps of Merge Sort. - Answers Divide the array into two halves.
Recursively sort each half.
Merge the sorted halves back into a single sorted array.
some common use cases for Merge Sort - Answers Suitable for large datasets, external sorting (when
data doesn't fit in memory), and linked lists
How is Merge Sort different from Quick Sort - Answers Merge Sort consistently runs in O(n log n) time,
while Quick Sort can degrade to O(n²) in the worst case. Merge Sort uses extra space; Quick Sort sorts in
place.
How does mergesort go? - Answers Divides arrays into subarrays and works backwards, merging it all
back together
Heap - Answers specialized tree-based data structure that satisfies the heap property, either as a max-
heap or a min-heap.
max-heap - Answers complete binary tree where each node's value is greater than or equal to its
children's values.
min-heap - Answers complete binary tree where each node's value is less than or equal to its children's
values.
How are heaps typically implemented? - Answers using arrays, where for a node at index iii, its left child
is at 2i+1 and right child is at 2i+2
time complexity for inserting an element into a heap - Answers O(log n), due to the need to maintain the
heap property after insertion.
time complexity to build a heap from an array - Answers O(n)
primary use of heaps in algorithms - Answers min-heap = priority queues
max-heap = heapsort
difference between a binary heap and a binary search tree (BST) - Answers binary heap maintains a
specific ordering based on parent-child relationships, while a BST maintains order based on in-order
traversal properties.