Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Name your file LinkedintList.java and submit on Canvas. You may download the client code from here and check your implementations: LinkedintListClient.java Your LinkedIntList.java has to

image text in transcribed
image text in transcribed
Name your file LinkedintList.java and submit on Canvas. You may download the client code from here and check your implementations: LinkedintListClient.java Your LinkedIntList.java has to work with the given client code. ** You should submit only the LinkedintList.java (5 Points) Write a method add that appends the given value to the end of the list. Also write a toString method that returns a string. In the form of "data1 ->data2 -> ... > dataN -> null" when the list is not empty and returns "I l" when the list is empty. (10 Points) Write a method delete2ndBack that deletes the 2nd to last value (from the back of the list) and returns the deleted value. If the list is empty or the size is less than 2. your method should throw a NoSuchElementException For example, suppose that a variable list is as follows: front-> 1 -> 2 -> 3 -> 4 -> null the call delete 2ndBacki ); should rearrange the list as follows and retur 3: front-> 1.> 2 -> 4 -> null Then the 2nd call delete 2ndBack(); should rearrange the list as follows and return 2: front-> 1 -> 4.> null The 3rd call delete2nd Backi ); should rearrange the list as follows and return 1: front => 4 -> null Finally the 4th delete2ndBackl): should not rearrange the list and throw a NoSuch ElementException, list should be as follows: front-> 4 -> null Add the methods to the LinkedintList class we have worked in class. You may not call any other methods of the class to solve this problem, you may not construct any new nodes and you may not use any auxiliary data structures to solve this problem Isuch as array ArrayList.Queue String, etc.). You also may not change any data fields of the nodes. You must solve this problem by rearranging the links of the list. LinkedIntListClient.java Download LinkedintListClient.java (961 Bytes) ); public class LinkedIntListclient { public static void main (String[] args) { LinkedIntList list = new LinkedIntList(); System.out.println ("Adding 1 -> 2 -> 3 -> 4 -> null to the list... list.add (1); list.add (2); list.add(3); list.add (4); System.out.println (list); System.out.println ("calling delete2ndBack..."); list.delete2ndBack(); System.out.println (list); System.out.println ("calling delete2ndBack..."); list.delete2ndBack(); System.out.println (list); System.out.println ("calling delete2ndBack... "); list.delete2ndBack(); system.out.println (list); System.out.println("calling delete2ndBack..."); tryc list.delete2ndBack(); } catch (Exception e) { System.out.println (e); > system.out.println("Final List : " + list)

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_2

Step: 3

blur-text-image_3

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

4. What decision would you make and why?

Answered: 1 week ago

Question

3. Review the evidence. Do you believe the testimony presented?

Answered: 1 week ago

Question

1. What are the marketing implications of this situation?

Answered: 1 week ago