Question: go to https://repl.it/@YBYUN/List After that, add three new functions named insert() , search() , and reverse(). . The overloaded function insert() adds the item at

go to https://repl.it/@YBYUN/List After that, add three new functions named insert(), search(), and reverse().

.

The overloaded function insert() adds the "item" at the end of the list. Note that this function has only one argument.

void insert(int item);

For example, if a list contains 20, 30, and 70, insert(10) should make the list become 20, 30, 70, and 10. The size of the list should be 4. In other words, the function should append the item to the list.

The function search() returns the position (= index) of a specified value if it exists in the list. If the value doesn't exist, your function should return -1.

This is the member function prototype:

int search(int value);

For example, if a list contains 10, 15, 7, 30, and 20, search(7) should return 2. For search(100), it should return -1.

The function reverse() reverses the elements of the list.

void reverse();

For example, if a list contains 10, 15, 7, 30, and 20, the function should reverse it (= 20, 30, 7, 15, 10). As another example, if a list contains 1234 and 2000, the function should reverse it (= 2000, 1234).

Sample Test Program:

// This is a sample program to test the new functions.

// Read the execution result of the program very carefully

// to identify the operations of new functions

int main()

{

List intList;

intList.insert(20, 0);

intList.insert(10, 0);

intList.insert(30);

intList.display();

intList.reverse();

intList.insert(15);

intList.display();

intList.reverse();

intList.display();

cout << intList.search(20) << endl;

cout << intList.search(100) << endl;

return 0;

}

Execution Result:

10 20 30

30 20 10 15

15 10 20 30

2

-1

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