Question: QUESTION:4 Insertion sort in an array (Bonus) In this assignment, we need to have our list implemented as a normal Array (neither vector nor Linked

QUESTION:4 Insertion sort in an array (Bonus) In this assignment, we need to have our list implemented as a normal Array (neither vector nor Linked list) TSortedArrayList. So, we already have all elements contiguous in memory. Yet, we have to take care of adding a new element to a full array. In this case, we have to allocate a larger array and copy elements from the old array to the new one, delete the old array and then insert the element in the new array. Also, with insertion sort, we mean that we always keep the array sorted in a descending order, thus, we have to scan the array to determine the insertion position, then if the insertion position is in the middle of the array, we have to move the elements to the right of the insertion position (those of smaller or equal value) on cell to the right. This will makeroom for the new element. For deletion, we have to move elements to right of the deleted element one cell to the left.Another strategy is to just mark the cell as deleted and do not actually move anything around to save time. Yet, when inserting new elements, we have to account for whether the cell content is actual or deleted
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
