Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The list works like this: entries begin at index 0 the size of the list is limited ( capped ) ; when the

The list works like this:
entries begin at index 0
the size of the list is limited ("capped"); when the size is reached, no more entries can be added
entries can only be added to and removed from the front or back of the list
entries can be accessed in any position
Write a class that implements this interface. The class uses linked nodes to implement the list.
requirements:
Class Header and Instance Data Variables
Your class header and instance data variables will be:
public class LinkedFrontBackCappedList implements FrontBackCappedList {
private Node head, tail;
Use the same nested Node class that is used in LList. I have provided a shell file for you to start with.
You CAN add additional variables other than head and tail.
For Full Credit:
You must use a head and tail reference!
Note that these are singly-linked nodes (meaning they only have "next" and do not have "previous").
You have two of these singly-linked nodes: head and tail.
Implement an efficient solution when possible.
All of the methods in the class should be O(1) or O(n).
O(n2) methods will not receive full credit.
Make sure to account for special conditions such as empty lists and singleton lists.
Your code should not crash under these conditions.
Carefully consider what the values of head and tail will be for an empty and singleton list!
You must implement every method from the interface.
Follow the API descriptions from the interface file and the additional method characteristics listed below.
Class Requirements
I strongly recommend working on the methods below in the order listed. Just like in Project A, the tester program relies on some methods to be working to test other methods. Hopefully writing these in order will help make sure that the tester is working as intended!
(3 points) constructor(int)
the parameter specifies the maximum size (i.e., capacity) that the list can be
(6 points) String toString()
the output must contain:
the size
the capacity (max size)
a display of all elements in the list
when the list is not empty, the output should include the head and tail values
see the driver program for the format of the text representation- your display must match this format!
Note: I strongly recommend writing the toString method right after the constructor because the tester will be much less useful without this method written!
(1 points) boolean isEmpty()
(1 points) boolean isFull()
(1 points) int size()
(5 points) T getEntry(int)
null should be returned when an invalid position is passed in as a parameter
(2 points) void clear()
(12 points) boolean addFront(T)
when there is room to add an element, the new element is added to the beginning of the list; true is returned
when the list is full, no changes are made to the list and false is returned
(12 points) boolean addBack(T)
when there is room to add an element, the new element is added to the end of the list and true is returned
when the list is full, no changes are made to the list and false is returned
(12 points) T removeFront()
the element is removed from the front
null is returned from an empty list
(15 points) T removeBack()
null is returned from an empty list
(5 points) boolean contains (T)
(5 points) int indexOf(T)
(5 points) int lastIndexOf(T)
Style and Efficiency
(15 points) Style and Efficiency
use a head and tail reference of singly-linked nodes
ensure that all methods are O(1) or O(n)
follow Java coding conventions (Links to an external site.)
follow general best practices and principles of object-oriented programming
properly format and indent code
follow naming conventions for variables, classes, and methods
reduce duplicated code. To use the driver without the extra credit, you either need to comment out the runExtraCreditTests AND testCompareTo methods or update the class header and add an empty compareTo method in your list class. The tester won't compile otherwise.Remove package statements from all files so that no classes are in a named package.
Upload your .java file.
file must compile .no extra credit

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

Step: 3

blur-text-image

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

List noteworthy changes that were implemented in DSM-5.

Answered: 1 week ago