Skip to content
Activities · Activity 5.3

Q.Consider a list of 10 elements: randList = [7,11,3,10,17,23,1,4,21,5]. Determine the partially sorted list after four complete passes of selection sort.

CBSENCERTSubjective· 3mImportance★★★★★
25% · 3/12 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

This problem requires tracing the Selection Sort algorithm for four complete passes on the given list randList = [7,11,3,10,17,23,1,4,21,5] to determine its state.

Selection Sort is an in-place comparison sorting algorithm. It works by repeatedly finding the minimum element from the unsorted part of the list and putting it at the beginning of the unsorted part.

The core idea is to divide the list into two parts: a sorted sublist and an unsorted sublist. Initially, the sorted sublist is empty, and the unsorted sublist is the entire list.

How Selection Sort Works (One Pass):

In each "pass" (or iteration), the algorithm performs the following steps:

  1. It finds the smallest element in the unsorted sublist.
  2. It swaps this smallest element with the first element of the unsorted sublist.
  3. This effectively moves the smallest element to its correct position in the sorted sublist, and the boundary between the sorted and unsorted sublists shifts one position to the right.

For a list of NN elements, Selection Sort requires N−1N-1 passes to fully sort the list. After kk passes, the first kk elements of the list will be sorted and in their final positions.

Let's trace the given list randList = [7, 11, 3, 10, 17, 23, 1, 4, 21, 5] through four complete passes.

PassCurrent List StateUnsorted Sublist (highlighted)Minimum Element FoundIndex of MinimumElement at Current Sorted PositionSwap ActionList After Pass
Initial[7, 11, 3, 10, 17, 23, 1, 4, 21, 5][7, 11, 3, 10, 17, 23, 1, 4, 21, 5]----[7, 11, 3, 10, 17, 23, 1, 4, 21, 5]
1[7, 11, 3, 10, 17, 23, 1, 4, 21, 5][**7**, 11, 3, 10, 17, 23, 1, 4, 21, 5]167 (at index 0)Swap randList[0] (7) with randList[6] (1)[1, 11, 3, 10, 17, 23, 7, 4, 21, 5]

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.