Write a blog post analysing the efficiency and correctness of an algorithm.

• Analyse either the out-of-place selection sort algorithm, or the out-of-place insertion sort algorithm.
◦ Briefly explain the problem of sorting out-of-place, and how the algorithm works.
◦ Show code for the algorithm – this is the solution to Q2 or Q3 from the Week 9 exercises.
◦ Analyse the efficiency – see the previous page. For more marks, don’t just consider random lists; what about lists that are in order, or completely out of order?
◦ Analyse the correctness – see the previous page.
▪ Identify any necessary loop invariant(s).
▪ How does the invariant(s) guarantee that the output list will be in order?
▪ What is the loop variant?
◦ Compare either with the in-place version of the same algorithm, or an alternative out-ofplace sorting algorithm.

 

 

 

Sample Solution

This question has been answered.

Get Answer