Question: c + + Your task in this exercise is to implement the functions that have been left empty. These are: void prepend ( T value
c Your task in this exercise is to implement the functions that have been left empty. These are:
void prepend value;
The prepend function above takes in a value of type and add it to the start of the list. Care must be taken to preserve the existing data in the order
that it was before.
T removeLast;
The removelast function above removes the last element from the list and returns its value. Care must be taken to update the count correctly to
reflect the removal. If the action causes the Arraylist to have "too much unused capacity", then the capacity should be reduced. The notion of "too
much unused capacity" is defined as having strictly less than half of the capacity occupied by data. If this is the case, the capacity should be
reduced by cutting it in half.
T removeFirst;
The removeFirst function above removes the first element from the list and returns its value. Care must be taken to preserve the order of the
remaining data elements, and ensure that there is no empty space at the beginning. In addition we need to update the count correctly to reflect the
removal. If the action causes the ArrayList to have "too much unused capacity", then the capacity should be reduced. The notion of "too much
unused capacity" is defined as having strictly less than half of the capacity occupied by data. If this is the case, the capacity should be reduced by
cutting it in half.
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
