COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
How many steps needed to sort the following numbers using a selection sort. 5 1 12-5 16 2 12 14
|
8
|
|
6
|
|
7
|
|
5
|
Explanation:
Detailed explanation-1: -Step 1: Set Min to location 0 in Step 1. Step 2: Look for the smallest element on the list. Step 3: Replace the value at location Min with a different value. Step 5: Continue until the list is sorted.
Detailed explanation-2: -What will be the number of passes to sort the elements using insertion sort? Explanation: The number of passes is given by N-1. Here, N=6.
Detailed explanation-3: -Explanation: Even though the first two elements are already sorted, bubble sort needs 4 iterations to sort the given array.
Detailed explanation-4: -So 2 swaps are needed to make the array sorted in ascending order.
There is 1 question to complete.