Data Structures and Algorithms - Old Questions
7. Trace selection – sort algorithm for the following data:
42, 23, 74, 11, 65, 58, 94, 86
5 marks
|
Asked in 2070
Selection sort algorithm sorts the elements in an array by finding the minimum element in each pass from unsorted part and keeps it in the beginning. This sorting technique maintains two sub arrays, one sub array which is already sorted and the other one which is unsorted. In each iteration the minimum element (ascending order) is picked from unsorted array and moved to sorted sub array.
Given data:
42, 23, 74, 11, 65, 58, 94, 86
Tracing using selection sort;
Which is the sorted array.