PadhaikoAll subjects

Past exam question: 2074 Bhadra (Regular), Q8

Data Structure and Algorithms · 10 marks

Open in the Padhaiko app

Topic: Sorting Algorithms

Question

Explain selection sort. Sort data sequence 40 90 20 -10 30 5 60 100 80 using selection sort method.

Solution

Selection Sort Algorithm: Selection sort repeatedly selects the smallest element from the unsorted subarray A[i..n-1] and swaps it into position A[i] for . It performs comparisons in all cases ( time, space).

Pass-by-Pass Trace on [40, 90, 20, -10, 30, 5, 60, 100, 80]:

Answer:

Sorted sequence: -10, 5, 20, 30, 40, 60, 80, 90, 100.

All past exam questions for Data Structure and Algorithms