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
-
Discussion question Discuss your personal growth in your understanding of the impact of effective leadership in organizations. Survey Do you think it is the manager's responsibility to establish the...
-
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...
-
Give examples of commodities whose demand you would expect to be elastic and commodities whose demand you would expect to be inelastic.
-
If = .05, df Rows = 3, df Columns = 1, df Interaction = 3, and df Within = 40, find (a) F cv Rows , (b) F cv Columns , and (c) F cv Interaction .
-
Perform sensitivity analysis in response to changing business conditions
-
Hollowell Audio, Inc., manufactures military-specification compact discs. The company uses standards to control its costs. The labor standards that have been set for one disc are as follows: During...
-
Use substitution to determine whether the given ordered pairs are solutions of the given equation. (3. ). (1 2 ): 6X - dy = 4
-
The Chartered Financial Analyst (CFA) designation is the de facto professional certification for the financial industry. Employers encourage their prospective employees to complete the CFA exam....
-
current ratio= current asset/ current liabilities=1.67 (2019 most recent fiscal year) current ratio=1.76(2018 prior fiscal year) canadian tire company analysis 1:Why this ratio might be of interest...
-
What is the result after the value of i is equal to 3? However, which of the Python structure statement controls the flow of the execution of break statement? i = 1 while i < 6: print(i) if i == 3:...
-
Why do we not adjust the FCFF when the manager says cannibalization is not "incremental" because it happens whether we accept or reject the project? Explain.
-
A rule is provided for each scenario below. You can find a case to interpret that rule and to assist you in completing your IRAC analysis when needed but be sure you cite the case(s) used to support...
-
Sparrow Company uses the retail inventory method to estimate ending inventory and cost of goods sold. Data for 2024 are as follows: Beginning inventory Cost $ 82,000 Retail $ 172,000 Purchases...
-
Inverse Square Law (Electrostatics) - calculate the charge & record your answers with the correct abbreviation for the standard unit: 1) If an object has a charge of 6 coulombs at 6 mm, what will be...
-
Saved Benson Manufacturing Company established the following standard price and cost data. Sales price Variable manufacturing cost Fixed manufacturing cost Fixed selling and administrative cost $...
-
$10,000 was borrowed at 3.5% on July 17. The borrower repaid $5000 on August 12, and $2000 on September 18. What final payment is required on November 12 to fully repay the loan?
-
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...
-
Application of materials handling costs A manufacturing company budgets the follow- ing costs for its materials handling operations: The company estimates that during the coming year, the materials...
-
Journal entries for payroll and payroll costs Arbocodiel Company employs five office employees whose monthly pay is as follows: In addition to the above salaries, Arnold earned a $300 bonus and...
-
Payroll and payroll costs Following are the August payroll data for Sabul Company: The FICA tax rate on employees and employers is 7 percent of pay. Workers' compensation is .06 percent. Only $11,000...
Study smarter with the SolutionInn App