C++ selection sort and insertion sort

I would like it if someone would check my answers to make sure I am understanding the sorts properly.  Please and thank you.

Consider the array based list of (10, 4, 8, 2, 7) as input for selection sort and insertion sort algorithms in the following questions:

The number of comparisons made by the selection sort is:   3
The number of comparisons made by the insertion sort is:   7
Note that each swap requires 3 moves.  The number of moves made by the selection sort is:   9
The number of moves made by the insertion sort is:   7
veeaechoneAsked:
Who is Participating?
 
jhp333Connect With a Mentor Commented:
The number of comparison by selection sort is always n(n-1)/2, which is 10 when n=5.
0
 
veeaechoneAuthor Commented:
Got it!  Thanks for your help!
0
All Courses

From novice to tech pro — start learning today.