Question 10
You write an algorithm to sort N numbers (stored in an array a[0] to a[N-1]) as follows: Algorithm steps: i. Search through the list of numbers to find the lowest number - say it is position "i" ii. Move a[i-1] to a[i], a[i-2] to a[i-1] etc, till a[0] to a[1] iii. Place the original a[i] in position 0 iv. Repeat the above steps but now starting from position 1 to N-1, then 2 to N-1 etc till all numbers are in the correct places. What is the running complexity of this algorithm?
linear
quadratic
cubic
exponential