Write a generic linked list class named AdaptiveList

Assignment Help JAVA Programming
Reference no: EM131688978

Assignment: An Adaptive List - Topic: Computer Science (data structure java)

Introduction

This assignment gives you an opportunity to work with a linked data structure by implementing the java.util.List and java.util.ListIterator interfaces through an adaptive list. This adaptive list is a doubly linked list complemented by an array for indexed read operations (like get(int pos))andindexedwriteoperations(like set(int pos, E obj)). The adaptive list is much more e!cient than the doubly linked list for supporting a long sequence of indexed read/write operations ?anked by add() and remove() operations.

Requirements of the AdaptiveList class

Write a generic linked list class named AdaptiveList. Your class must implement the java.util.List interface. You may find it helpful to read the Javadoc for the interface along with its iteratorsubinterface. All the methods except subList method in the interface as well as a few additional methods must be implemented with-out throwing an UnsupportedOperationException. You may throw an UnsupportedOperationException for the subList method. Note that for some of the methods, we provide their implementations as examples for you to study or for showing the list/array created by your code; you just need to implement the other methods with the comment line // TODO. You are not allowed to use any Collection class in your implementation.

The AdaptiveList class has a non-static inner class named ListNode whose in- stances serve as nodes in the doubly linked list. The inner class has three member variables: data of generic type E, link of type ListNode, prev of type ListNode, No additional member variables in the ListNode class are allowed. The link field of a node refers to its successor node in the list if the successor node exists and is null otherwise. The prev field of a node refers to its predecessor node in the list if the predecessor node exits and is null otherwise. Every AdaptiveList list must have two dummy nodes named head and tail along with normal nodes. The list is empty if it has no normal nodes. If the list is empty, then head is the predecessor of tail and tail is the successor of head. Otherwise, head is the predecessor of the first normal node and the first normal node is the successor node of head; tail is the successor of the last normal node and the last normal node is the predecessor of tail. The data fields of head and tail are always null. The prev field of head and the link field of tail are always null.

Write a private inner class named AdaptiveListIterator to implement the ListIterator interface. You should implement all methods in the ListIterator interface without throwing any UnsupportedOperationException. There is no need to keep a coherent list if there is concurrent modi?cation to the list. In other words, the iterator does not have to be a failfast iterator.

In addition to the doubly linked list, the AdaptiveList class keeps an array of type E elements for implementing the get(int pos), set(int pos, E obj) and reverse() methods efficiently. Note that the reverse() method swaps the elements at indexes 0 and n ! 1, at indexes 1 and n ! 2, and so on, so that the order of the elements in the array of length n is reversed. The method returns false if n ≤ 1 and true otherwise. This method needs to be implemented without using any additional array.

The doubly linked list and the array are alternately used as follows. The class keeps two boolean ?elds named linkedUTD and arrayUTD (UTD stands for Up To Date): linkedUTD is true if the doubly linked list is used to represent the current sequence of data items and false otherwise; arrayUTD is true if the array is used to represent the current sequence of data items and false otherwise. At any time, the current sequence of data items is represented either by the doubly linked list or by the array; so at least one of linkedUTD and arrayUTD is true. The doubly linked list is used to implement all methods except for the get(int pos), set(int pos, Eobj) and reverse() methods, which are implemented by using the array. These implementations are facilitated by using two helper methods: The updateLinked() method creates a new doubly linked list with numItems normal nodes by copying the current sequence of data items from the array to the doubly linked list and setting linkedUTD to true, whereas the updateArray() method creates a new array of length numItems by copying the current sequence of data items from the doubly linked list to the array and setting arrayUTD to true. If a method is to be implemented by using the doubly linked list but linkedUTD is false, then updateLinked() needs to be called before the implementation and at the end arrayUTD needs to be set to false if the doubly linked list is modi?ed by the method so that the array is no longer up to date. Similarly, if a method is to be implemented by using the array but arrayUTD is false, then updateArray() needs to be called before the implementation and at the end linkedUTD needs to be set to false if the array is modi?ed by the Set() or reverse() method (see the following example).

Attachment:- Assignment Files.rar

Reference no: EM131688978

Questions Cloud

Demonstrate college-level communication through composition : Demonstrate college-level communication through the composition of original materials in Standard English.
Compute probability that committee will contain none of them : The dean of a business school wishes to form an executive committee of 5 from among the 40 tenured faculty members at the school.
Compare and contrast that strategy to innovative strategy : Identify their big idea that started the company's innovation and describe their strategy at that time. Compare and contrast that strategy to their innovative
Explain mediation-third party negotiation and arbitration : Explain mediation, third party negotiation, and arbitration. What are the differences between each?
Write a generic linked list class named AdaptiveList : Com S 228 Assignment: An Adaptive List. Write a generic linked list class named AdaptiveList. Your class must implement the java.util.List interface
Find probability that cars arrive at a particular dealership : From an inventory of 30 cars being shipped to a local automobile dealer, 4 are SUVs. What is the probability that if 4 cars arrive at a particular dealership.
List the components of the shoe : Explain why you removed those components and explain if it would create a new useful product or solve a problem
Least important for selling in the private label market : Rank each of following factors in order of most important to least important for selling in the private label market. Include short explanation for each ranking
Implications of his stores make these notifications : What are the ethical implications of his stores make these notifications?

Reviews

len1688978

10/24/2017 4:43:52 AM

Topic: Computer Science(data structure java). You are required to include, in your submission, the source code for each of the classes: A short template is given in package cs228hw3.zip. You need to write proper documentation with Javadoc for each method that you implement. Write your class so that its package name is edu.iastate.cs228.hw3. Your source ?les (.java ?les) will be placed in the directory edu/iastate/cs228/hw3 (Linux) or edu\iastate\cs228\hw3 (Windows), as de?ned by the package speci?ed above. Be sure to put down your name after the @author tag in each class source ?le. Your zip ?le should be named Firstname Lastname HW3.zip. You may submit a draft version of your code early to see if you have any submission problem with Blackboard Learn. We will grade only your latest submission.

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd