144 views

2 Answers

1 1 vote

Selection Sort places one element into its final position during every iteration.

For an array of $n$ elements:

  • Pass $1$ places one element correctly.
     
  • Pass $2$ places another element correctly.
     
  • This continues until only one element remains.
     

Therefore, only $n-1$ passes are required.

Since the standard Selection Sort implementation performs one swap at the end of each pass:

$\text{Number of swaps}=n-1$

Note : An important feature of Selection Sort is that the number of swaps does not depend on whether the input is sorted, reverse sorted, or randomly ordered. Selection Sort uses only about $N$ exchanges.

Answer:
Position:
Show:

Related questions

1 1 vote
2 2 answers
148
148 views
GO Classes asked Aug 11
148 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...
1 1 vote
2 2 answers
142
142 views
GO Classes asked Aug 11
142 views
When is insertionsort a good choice for sorting an array?Each component of the array requires a large amount of memory. Each component of the array requires a small amoun...
2 2 votes
2 2 answers
160
160 views
GO Classes asked Aug 11
160 views
The nontrivial operation involved in the bubble sort is comparing two numbers, i.e., checking the $\texttt{if}$ condition in the inner $\texttt{for}$ loop.How many compar...
2 2 votes
2 2 answers
170
170 views
GO Classes asked Aug 11
170 views
Problem: Sort a file of huge records with tiny keys.Example application: Reorganize your MP-$3$ files.Which sorting method to use?a system sort, guaranteed to run in time...