Question: This problem mirrors Exercise E4.6. For each of the questions in that exercise, implement a client method (i.e., a method that is outside the List

This problem mirrors Exercise E4.6. For each of the questions in that exercise, implement a client method (i.e., a method that is outside the List class) with the following specifications:

(a) void empty(List L)

(b) void removeAll(List L, T item)

(c) int size(List L)

(d) boolean contains(List L, T item)

Exercise E4.6

Suppose you are given a list that supports only the operations append, remove, and enumerate, as described in the first three rows of Table 4.1. Give an algorithm describing how you would perform each of the following operations in terms of the given operations.

(a) Empty a list (i.e., remove all the entries)

(b) Remove all occurrences of a given item from a list

(c) Obtain the size (i.e., the number of entries) of a list

(d) Search for a given item in the list, returning true or false depending on whether the item is found or not

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 Programming Questions!