0
0
DSA C++programming~5 mins

Selection Sort Algorithm in DSA C++ - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main idea behind the Selection Sort algorithm?
Selection Sort repeatedly finds the smallest element from the unsorted part and swaps it with the first unsorted element, growing the sorted part step by step.
Click to reveal answer
beginner
How many passes does Selection Sort make through the array?
Selection Sort makes n-1 passes through an array of n elements, because after placing n-1 elements, the last one is already sorted.
Click to reveal answer
intermediate
What is the time complexity of Selection Sort in the best, average, and worst cases?
Selection Sort has a time complexity of O(n²) in all cases because it always compares each element with the rest, regardless of initial order.
Click to reveal answer
beginner
Does Selection Sort require extra memory for sorting?
No, Selection Sort is an in-place sorting algorithm, meaning it sorts the array without needing extra memory beyond a few variables.
Click to reveal answer
intermediate
Why is Selection Sort not efficient for large datasets?
Because Selection Sort always does n² comparisons, it becomes slow for large datasets compared to faster algorithms like Quick Sort or Merge Sort.
Click to reveal answer
What does Selection Sort do in each pass?
ADivides the array into halves and sorts each half
BSwaps adjacent elements if they are in the wrong order
CFinds the smallest element and swaps it with the first unsorted element
DUses a pivot to partition the array
How many swaps does Selection Sort perform in the worst case?
An-1 swaps
Bn² swaps
C0 swaps
Dn swaps
Which of these is true about Selection Sort's space complexity?
AIt sorts in-place using constant extra space
BIt requires extra space proportional to n
CIt needs a temporary array to store sorted elements
DIt uses recursion and stack space
What is the best case time complexity of Selection Sort?
AO(n log n)
BO(n)
CO(log n)
DO(n²)
Which sorting algorithm is generally faster than Selection Sort for large arrays?
ABubble Sort
BQuick Sort
CSelection Sort
DInsertion Sort
Explain step-by-step how Selection Sort sorts the array [4, 2, 7, 1].
Think about how the smallest number moves to the front each time.
You got /4 concepts.
    Describe why Selection Sort is considered an in-place sorting algorithm and what that means for memory use.
    Focus on how the array is changed directly.
    You got /4 concepts.