The implementation of the Generic SinglyLinked List that was covered in class is missing some important...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The implementation of the Generic SinglyLinked List that was covered in class is missing some important operations. Complete the implementation by proving the code for the methods described below. Test your code to make sure that your List is working properly. The complete design of the class is shown below: ● ● ● ● SinglyLinkedList -head: Node<E> -tail: Node<E> -size: int +SingleLinkedList() +length(): int +isEmpty(): boolean +getFirst(): E +getLast(): E +addFirst(e: E): void +addLast(e: E): void +removeFirst(): E +get(n: int): E +insertAfter(n: int, e: E): void +delete(n: int): void -head -tail Node +element: E +next: Node<E> +Node(e: E, n: Node<E>) +getElement(): E +getNext(): Node<E> +setNext(n: Node<E>): void E removeLast() Remove the last element from the List and return it. If the List is empty, return null. E get (int n) Return the nth element of the List. The first element is number 0. If n ≥ length(), return null. void insertAfter(int n, E e) Insert the element e after the nth element of the List. If n ≥ length(), do not insert the element. No error is returned or exception raised. void delete(int n) Remove the nth element of the List (including n=0). If n ≥ length(), do not delete an element. No error is returned or exception raised. When your implementation is complete, run it with the test driver Enhanced ListTester.java (provided). Review the results to make sure that your modified class is working correctly. Your output must include your name. 2. Notes Start with the partially implemented code found with this assignment: SinglyLinked List.java. The class Node is defined as a private inner class of Singly Linked List. Turn in only your modified source files: SinglyLinked List.java and Enhanced List Tester.java. Make sure your class is not in a package (that is, it is in the default package). You will not need to modify Enhanced List Tester.java, except to add your name. 3. Required Main Class Enhanced List Tester, provided 4. Required Input Not pplicable 5. Required Output No example is given. Review your results based on your understanding of List operations to ensure that your modified class is working correctly. 0:[] 1: [Alpha] 2: [Alpha, Tester Dava Application) C\Program FilesVavalidk-18.0 Beta] 3: [Gamma, Alpha, Beta] 4: [Gamma, Alpha, Beta, Delta] First is Gamma Last is Delta Rotated 4: [Alpha, Beta, Delta, Gamma] Rotated 4: [Beta, Delta, Gamma, Alpha] Rotated 4: [Delta, Gamma, Alpha, Beta] Rotated 4: [Gamma, Alpha, Beta, Delta] Removing Gamma Removing Alpha Removing Beta Removing Delta 0:[] The implementation of the Generic SinglyLinked List that was covered in class is missing some important operations. Complete the implementation by proving the code for the methods described below. Test your code to make sure that your List is working properly. The complete design of the class is shown below: ● ● ● ● SinglyLinkedList -head: Node<E> -tail: Node<E> -size: int +SingleLinkedList() +length(): int +isEmpty(): boolean +getFirst(): E +getLast(): E +addFirst(e: E): void +addLast(e: E): void +removeFirst(): E +get(n: int): E +insertAfter(n: int, e: E): void +delete(n: int): void -head -tail Node +element: E +next: Node<E> +Node(e: E, n: Node<E>) +getElement(): E +getNext(): Node<E> +setNext(n: Node<E>): void E removeLast() Remove the last element from the List and return it. If the List is empty, return null. E get (int n) Return the nth element of the List. The first element is number 0. If n ≥ length(), return null. void insertAfter(int n, E e) Insert the element e after the nth element of the List. If n ≥ length(), do not insert the element. No error is returned or exception raised. void delete(int n) Remove the nth element of the List (including n=0). If n ≥ length(), do not delete an element. No error is returned or exception raised. When your implementation is complete, run it with the test driver Enhanced ListTester.java (provided). Review the results to make sure that your modified class is working correctly. Your output must include your name. 2. Notes Start with the partially implemented code found with this assignment: SinglyLinked List.java. The class Node is defined as a private inner class of Singly Linked List. Turn in only your modified source files: SinglyLinked List.java and Enhanced List Tester.java. Make sure your class is not in a package (that is, it is in the default package). You will not need to modify Enhanced List Tester.java, except to add your name. 3. Required Main Class Enhanced List Tester, provided 4. Required Input Not pplicable 5. Required Output No example is given. Review your results based on your understanding of List operations to ensure that your modified class is working correctly. 0:[] 1: [Alpha] 2: [Alpha, Tester Dava Application) C\Program FilesVavalidk-18.0 Beta] 3: [Gamma, Alpha, Beta] 4: [Gamma, Alpha, Beta, Delta] First is Gamma Last is Delta Rotated 4: [Alpha, Beta, Delta, Gamma] Rotated 4: [Beta, Delta, Gamma, Alpha] Rotated 4: [Delta, Gamma, Alpha, Beta] Rotated 4: [Gamma, Alpha, Beta, Delta] Removing Gamma Removing Alpha Removing Beta Removing Delta 0:[]
Expert Answer:
Answer rating: 100% (QA)
To complete the implementation of the SinglyLinkedList class we need to add the following methods removeLast Remove the last element from the list and ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
developing the Singly-Linked LinkedList data structure, which will implement the provided List interface. In doing so, you will writea variety of methods from each. You will also be creating your own...
-
Select the necessary words from the list of possibilities to complete the following statements. Statements 1. The of SEC registrants selects the company's audit firm. 2. The auditors must assess the...
-
On October 29, 2016, Lobo Co. began operations by purchasing razors for resale. Lobo uses the perpetual inventory method. The razors have a 90-day warranty that requires the company to replace any...
-
Create a program that implements a sort algorithm of your choice and applies it to a random vector of 1,000 elements Repeat the process applying it to random vectors of 2,000, 3,000, ... up to 10,000...
-
A long-term care facility (50 beds) in the Midwestern U.S. has just been acquired by a larger acute care hospital/health care system in the nearby city because they want to offer services across the...
-
You are the human resources manager for a famous retailer, and you are trying to convince the president of the company to change the structure of employee compensation. Currently, the companys retail...
-
Exercise 2 - 2 4 ( Static ) Special journals [ Appendix 2 C ] The accounting system of a company consists of a general journal, a cash receipts journal, a cash disbursements journal, a sales...
-
Obtain a state-space model for the RLC circuit depicted below. Here, the system has two input voltages u and u [V] and three output voltages 91, 92 and y3 [V], as indicated in the figure. R...
-
Results have been reported on the performance of a crystallizer operating on sodium chloride. Results from one experiment are Tip speed u T = 1.350 ft/min Retention time = 1.80 h Time between...
-
Which security should sell at a greater price? a. A 10-year Treasury bond with a 4% coupon rate versus a 10-year T-bond with a 5% coupon. b. A 3-month expiration call option with an exercise price of...
-
Governments invest in education and infrastructure for their citizens, in part to gain a competitive advantage in world markets. Could a government invest too much in education? Could a government...
-
"Thomas Malthus developed a formal model of a dynamic growth process in which each country converged toward a stationary per capita income. According to this model, death rates fall and fertility...
-
Label each of the following statements as either true (T) or false (F). 1. Relevant costs are also known as unavoidable costs. 2. Incremental costs are also known as differential costs. 3. An...
-
Paragraph has seven errors: article (2), word form (1), subject-verb agreement (2), and verb form (2). Find and correct them. Taking proper care of ones health also leads to better social life. The...
-
In a certain school district, 3% of the faculty use none of their sick days in a school year. Find the probability that 5 faculty members selected at random used no sick days in a given year.
-
Phil and Linda are 25-year-old newlyweds and file a joint tax return. Linda is covered by a retirement plan at work, but Phil is not. a. Assuming Phil's wages were $27,000 and Linda's wages were...
-
Robert Ramos (age 36) is a single taxpayer, living at 8765 Bay Dr., Monterey, CA 93940. His Social Security number is 976-23-5132. Robert's earnings and income tax withholding as the manager of a...
-
For each of the following situations, indicate whether the taxpayer(s) is (are) required to file a tax return for 2012. Explain your answer. a. Helen is a single taxpayer with interest income in 2012...
-
A man in a barrel walking competition is moving along smoothly, with his barrel moving forward at 1.0 m/s. a. Think about how the man moves his legs. Is he walking forward or backward? b. From the...
-
A 17 g audio compact disk has a diameter of 12 cm. The disk spins under a laser that reads encoded data. The first track to be read is 2.3 cm from the axis; as the disk plays, the laser scans tracks...
-
A spin bike is an indoor bike that is designed to duplicate the feeling of regular road cycling. A typical spin bike has a very heavy flywheel. A friction pad or other brake provides damping that...
Study smarter with the SolutionInn App