Download the code lab2.cpp to your account using copy/paste into vi, wget or cp. This code contains a basic array-based list without an implemented insertion function. The code will compile as given, but it will not actually do anything useful since insertion is not implemented.
Add the body of the insertion function using the following pseudocode as given in lecture on Monday:
Insertion Given - the element to insert and the index to insert at Returns - boolean to indicate success/failure (Validate the index number. Valid between 0 and count) if index < 0 or index > count print/raise "invalid index" error return false end-if (Check if the list has space) if count is equal to max size/capacity print/raise "list full" error return false end-if (Shift the elements up by one to make room for inserted element) for i = count to i > index, i-- array[i] = array[i-1] end-for (Set the element and update count) array[index] = element increment count return trueEmail the updated lab2.cpp file to the address terry on Sleipnir (type terry into the To field and hit tab or enter). All labs will be emailed to Terry for the rest of the quarter, but homework assignments will be emailed to me (type melissa in the To field).