edited by
12,743 views

3 Answers

Best answer
12 12 votes

From Wikipedia 

Selection sort is not difficult to analyze compared to other sorting algorithms since none of the loops depend on the data in the array. Selecting the lowest element requires scanning all nelements (this takes n − 1 comparisons) and then swapping it into the first position. Finding the next lowest element requires scanning the remaining n − 1 elements and so on, for (n − 1) + (n − 2) + ... + 2 + 1 = n(n − 1) / 2 ∈ Θ(n^2) comparisons.

 
 So whatever order they are arranged the number of comparisons will be sum of n-1 terms. 
Here n=5
So total comparisons= 4*(4+1)/2=10.
 
 
selected by
4 4 votes

b) 10


each cell denote the total number of comparison performed to select the element to be placed in that cell.

4 3 2 1 0
2 2 votes
The number of comparisons needed will be..

1st Iteration - 4

2nd Iteration - 3

3rd Iteration -2

4rth Iteration -1

So to fully sort - 4+3+2+1 = 10 comparisons are needed.
Answer:
Position:
Show:

Related questions

55 55 votes
3 answers 3 answers
18.1k
18.1k views
Arjun asked Sep 23, 2014
18,132 views
Which one of the following is the tightest upper bound that represents the number of swaps required to sort $n$ numbers using selection sort?$O(\log n$)$O(n$)$O(n \log n$...
43 43 votes
2 answers 2 answers
35.5k
35.5k views
Kathleen asked Sep 22, 2014
35,534 views
What is the number of swaps required to sort $n$ elements using selection sort, in the worst case?$\Theta(n)$$\Theta(n \log n)$$\Theta(n^2)$$\Theta(n^2 \log n)$
3 3 votes
2 2 answers
154
154 views
GO Classes asked Aug 12
154 views
What effect does the initial ordering of the records have on the number of comparisons performed by standard Selection Sort?No effect Only a constant-factor difference Th...
1 1 vote
2 2 answers
138
138 views
GO Classes asked Aug 11
138 views
Suppose that a selectionsort of $100$ items has completed $42$ iterations of the main loop. How many items are now guaranteed to be in their final spot (never to be moved...