0
0
DSA Javascriptprogramming~5 mins

Selection Sort Algorithm in DSA Javascript - 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 moves it to the beginning, sorting the list step by step.
Click to reveal answer
beginner
How many passes does Selection Sort make over the array?
Selection Sort makes n-1 passes over 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 average and worst cases?
The time complexity is O(n²) because it uses two nested loops: one to select the position and one to find the minimum element.
Click to reveal answer
beginner
Does Selection Sort require extra space for sorting?
No, Selection Sort sorts the array in place and requires only a constant amount of extra space (O(1)).
Click to reveal answer
beginner
Show the first step of Selection Sort on the array [29, 10, 14, 37, 13].
Find the smallest element (10) and swap it with the first element (29). The array becomes [10, 29, 14, 37, 13].
Click to reveal answer
What does Selection Sort do in each pass?
AFinds the smallest element and swaps it to the front
BSwaps adjacent elements if they are in wrong order
CDivides the array into halves and sorts each
DBuilds a heap to sort elements
What is the best case time complexity of Selection Sort?
AO(n log n)
BO(n²)
CO(n)
DO(log n)
How much extra memory does Selection Sort need?
AO(n²)
BO(log n)
CO(n)
DO(1)
Which of these is true about Selection Sort?
AIt is a stable sorting algorithm
BIt is faster than Quick Sort on large arrays
CIt is an unstable sorting algorithm
DIt uses divide and conquer
After the first pass of Selection Sort on [5, 3, 8, 4], what is the array?
A[3, 5, 8, 4]
B[5, 3, 8, 4]
C[3, 4, 5, 8]
D[4, 3, 8, 5]
Explain how Selection Sort works step by step on a small array.
Think about how you pick the smallest item and place it at the start repeatedly.
You got /4 concepts.
    Compare Selection Sort with Bubble Sort in terms of time complexity and stability.
    Consider how each algorithm moves elements and whether equal elements keep their order.
    You got /4 concepts.