edited by
9,793 views

3 Answers

Best answer
8 votes
8 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
3 votes
3 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
1 votes
1 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:

Related questions

0 votes
0 votes
2 answers
2
naveen81 asked Jan 30, 2017
729 views
a. i>0,K>0, a[K] a[max]b. i>0,K<0, a[K]< a[max]c. i<0,K>0, a[K] a[max]d. i>0,K>0, a[K]< a[max]
1 votes
1 votes
1 answer
3
mcjoshi asked Aug 23, 2016
768 views
Why option (A) is not correct ?
6 votes
6 votes
1 answer
4
go_editor asked Jun 13, 2016
3,209 views
What is the value of $F(4)$ using the following procedure:function F(K : integer) integer; begin if (k<3) then F:=k else F:=F(k-1)*F(k-2)+F(k-3) end;$5$$6$$7$$8$