Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 - (10 Marks) Singly LinkedList - Use Netbeans 1) Add the following methods to MyL inkedList class that we implemented during the lectures:

image text in transcribed
Exercise 2 - (10 Marks) Singly LinkedList - Use Netbeans 1) Add the following methods to MyL inkedList 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, a new node is always inserted at the beginning of the linked list. Your method should prompt the user for the size of the linked list (number of nodes in the list), then generate random integer values between 1 to 50 and insert them to the list in backward manner. 7. Write a method buildListForward () that builds a list in forward manner, a new node is always inserted at the end of the linked list. Your method should prompt the user to enter a set of integer numbers then insert them to the list in forward manner. The reading stops when the user enters - 999 8. Write a method deletesmallest () that finds and deletes the node with the smallest info in the list. The method should delete the first occurrence and node traversal should be performed only once. 1/2 b) Test the methods above in a tester program as follows: 1. Build a linked list L of 10 nodes in backward manner 2. Print L1 3. Print the info of the first node in L1. Use proper output message. 4. Remove two nodes at the end of L1. Hint: call removeAtEnd () two times. 5. Print the info of the last node in L1. Use proper output message. 6. Check if L1 is empty. Use proper output message. 7. Build another linked list L 2 of 5 nodes in forward manner 8. Print L2 9. Delete the node with the smallest info in L2 10. Print L2 after deleting the smallest infd

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago