Question: a ) ( 1 0 pts ) Add the following methods to MyLinkedList class that we implemented during the lectures: 1 . Write a method

a)(10 pts) Add the following methods to MyLinkedList class that we implemented during the lectures:
1. Write a method isEmpty() that returns true if the list is empty and false otherwise
2. Write a method front() that returns the info value of the first node in the list
3. Write a method back() that returns the info value of the last node in the list
4. Write a method insertAtEnd() that inserts a new node at the end of the list
5. Write a method removeAtEnd() that removes the last node of the list
6. Write a method buildListBackward() that builds a list in backward manner by inserting nodes with
random values in a specified range. The method should prompt the user for two numbers that define
the range (minimum and maximum). It should also ask the user for the number of nodes to create.
Random integer values between the specified range are then generated and inserted at the beginning
of the list (backward manner)
7. Write a method buildListForward() that builds a list in forward manner by reading numbers from
a text file. Each number in the file represents a node to be added to the list in forward manner (inserted
at the end). The method should ask the user for the name of the file, read the integers from the file, and
insert each value as a node in the list.
8. Write a method replaceValue(int oldValue, int newValue) that replaces all occurrences of
oldValue with newValue in the list. Traverse the list only once.

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!