Question: In the lecture you learned about the InsertionSort algorithm. which runs through the elements of a list from left to right and sorts them in
In the lecture you learned about the InsertionSort algorithm. which runs through the elements of a
list from left to right and sorts them in ascending order. The aim of this task is to deepen your
understanding of the algorithm and to develop a mirrored variation of the algorithm.
a Rewrite InsertionSort so that the resulting algorithm traverses the elements from right to left
and sorts them in ascending order and justify your design. The insertion should be mirrored to the
original algorithm, ie on the right side of the array. The algorithm should continue to be
implemented iteratively, ie via an outer and an inner loop.
b Using the algorithm in sort the following array of strings alphabetically:
Before each run of the outer loop, specify the state of the partially sorted array and mark
the element currently being viewed. Also consider the execution of the loop, which is aborted
due to the loop condition.
c Prove the correctness of your algorithm from a
d In the divide and conquer approach, a problem is divided recursively into smaller subproblems that are
easier to solve, and then the solutions of these subproblems are merged to solve the overall
problem. The aim of this subtask is to create initial points of contact with this approach. To do this, design
the algorithm from as a recursive method RecursivelnsertionSortA
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
