Professional Documents
Culture Documents
SAQ 4 DS
SAQ 4 DS
NAME: K. ABINASH
CLASS: CSE-D
REG NO: AUU23EGCSE118
4. Demonstrate the selection sort results for each pass for the following
initial array of elements 21, 6 ,3 ,57 ,13 ,9 ,14 ,18 ,2.
Ans: Selection sort works by repeatedly finding the minimum element from the
unsorted part of the array and swapping it with the first unsorted element. Here's
a step-by-step demonstration of selection sort for the given array {21, 6, 3, 57,
13, 9, 14, 18, 2}:
Pass 1:
Pass 3:
Pass 4:
Pass 5:
Pass 6:
Pass 7:
Pass 8:
After the eighth pass, the array is fully sorted. Selection sort has a time
complexity of O(n^2), where n is the number of elements in the array.
5. Differentiate Quick sort and Merge sort techniques.
Ans: Quick sort and merge sort are both efficient sorting algorithms, but they
differ in their approaches and performance characteristics.