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...
-
Do the following structures represent identical molecules or a pair of enantiomers? a. b. c. d. CH and Ho CH2CH-CH3 CH CH CHH CH Br CI CI and CHs CH2CH CH CH2 CH2Br CH2Br "OH and CH Br Cl CH CH3...
-
In Problems 5358, convert each angle in radians to degrees. Express your answer in decimal form, rounded to two decimal places. 2
-
A copy of the state of a database at a specific point in time during the middle of a normal business day is called a(n) a. archive c. checkpoint b. cookie d. restoration
-
1. Did the intervention effort by the Thai government constitute direct or indirect intervention? Explain. 2. Did the intervention by the Thai government constitute sterilized or non-sterilized...
-
Q6. Use Newton-Raphson numerical method to find the root of the following equation: I (4 Marks)
-
The proposed rates were not in the range the CEO expected given the pricing analysis. The CEO has asked the pricing actuary to verify the total projected loss cost excluding potential large storm...
-
discuss an organizational real-life project. Name the organization Identify the basic elements of the project plan. Discuss how risk was or was not managed properly within the project. Discuss steps...
-
Q3(b).Your friend reports that they came across an alternative condominium with a 30% Internal Rate of Return over the same three-year investment period (much higher than the one you found above).You...
-
How do you calculate the budgeted quantity of input allowed for actual output when trying to figure out efficiency variance?
-
On Tuesday, the Reserve Bank announces details of a 160-day T-note tender, with competitive bids to close on Wednesday. A bank lodged a successful bid for $500 000 in T-notes at a yield of 5.57% per...
-
2. Estimate the unrealized gain/loss on this trade as of November 19 (two weeks after the initial transaction date). Assume the following: repo rate stays at 0.15% for the full two week period with...
-
Question 3 You won the lottery! However, in order to receive your first prize, you need to choose among the following pay-out options. The APR is 20%, compounded semi-annually. Option A: You will...
-
One of the main characteristics of Shouldice's operations is standardization. Specifically, each patient goes through almost the same steps through their stay in the hospital. How do you think this...
-
$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...
-
Debra Company reports the following financial information for the year: Accounts receivable: Based on prior experience the management of Debra Company expects two percent of credit sales to be...
-
1. In an effort to increase collections, Bishop Company offers a 1/10, n/30 discount for early payment. Assume a sale of \($150,000\) made on August Ist. Determine the total sales, the sales...
-
Consider the following balance sheet data for Davis Co., Inc., an electronics and major appliance retailer, at February 26, 2019 and February 27, 2018 (amounts in thousands): a. Prepare a comparative...
Study smarter with the SolutionInn App