Question: The function removeAt of the class arrayListType removes an element from the list by shifting the elements of the list. However, if the element to

The function removeAt of the class arrayListType removes an element from the list by shifting the elements of the list. However, if the element to be removed is at the beginning of the list and the list is fairly large, it could tak a lot of computer time. Because the list elements are in no particular order, you could simply remove the element by swapping the last element of the list with the item to be removed and reducing the length of the list. Rewrite the definition of the function removeAt using this technique.

See program exercise 1 on page 204.

The function remove of the class arrayListType removes only the first occurrence of an element. Add the function removeAll to the class arrayListType that would remove all occurrences of a given element. Also, write the definition of the function removeAll and a program to test this function.

See programming exercises 2 on page 204

Write a program to test the functions, removeAt and removeAll.

c++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!