Question: / * * * Your implementation of a CircularSinglyLinkedList without a tail pointer. * * @author YOUR NAME HERE * @version 1 . 0 *

/**
* Your implementation of a CircularSinglyLinkedList without a tail pointer.
*
* @author YOUR NAME HERE
* @version 1.0
* @userid YOUR USER ID HERE (i.e. gburdell3)
* @GTID YOUR GT ID HERE (i.e.900000000)
*
* Collaborators: LIST ALL COLLABORATORS YOU WORKED WITH HERE
*
* Resources: LIST ALL NON-COURSE RESOURCES YOU CONSULTED HERE
*/
public class CircularSinglyLinkedList {
/*
* Do not add new instance variables or modify existing ones.
*/
private CircularSinglyLinkedListNode head;
private int size;
/*
* Do not add a constructor.
*/
/**
* Adds the data to the specified index.
*
* Must be O(1) for indices 0 and size and O(n) for all other cases.
*
* @param index the index at which to add the new data
* @param data the data to add at the specified index
* @throws java.lang.IndexOutOfBoundsException if index 0 or index > size
* @throws java.lang.IllegalArgumentException if data is null
*/
public void addAtIndex(int index, T data){
}
/**
* Adds the data to the front of the list.
*
* Must be O(1).
*
* @param data the data to add to the front of the list
* @throws java.lang.IllegalArgumentException if data is null
*/
public void addToFront(T data){
}
/**
* Adds the data to the back of the list.
*
* Must be O(1).
*
* @param data the data to add to the back of the list
* @throws java.lang.IllegalArgumentException if data is null
*/
public void addToBack(T data){
}
/**
* Removes and returns the data at the specified index.
*
* Must be O(1) for index 0 and O(n) for all other cases.
*
* @param index the index of the data to remove
* @return the data formerly located at the specified index
* @throws java.lang.IndexOutOfBoundsException if index 0 or index >= size
*/
public T removeAtIndex(int index){
}
/**
* Removes and returns the first data of the list.
*
* Must be O(1).
*
* @return the data formerly located at the front of the list
* @throws java.util.NoSuchElementException if the list is empty
*/
public T removeFromFront(){
}
/**
* Removes and returns the last data of the list.
*
* Must be O(n).
*
* @return the data formerly located at the back of the list
* @throws java.util.NoSuchElementException if the list is empty
*/
public T removeFromBack(){
}
/**
* Returns the data at the specified index.
*
* Should be O(1) for index 0 and O(n) for all other cases.
*
* @param index the index of the data to get
* @return the data stored at the index in the list
* @throws java.lang.IndexOutOfBoundsException if index 0 or index >= size
*/
public T get(int index){
}
/**
* Returns whether or not the list is empty.
*
* Must be O(1).
*
* @return true if empty, false otherwise
*/
public boolean isEmpty(){
}
/**
* Clears the list.
*
* Clears all data and resets the size.
*
* Must be O(1).
*/
public void clear(){
}
/**
* Removes and returns the last copy of the given data from the list.
*
* Do not return the same data that was passed in. Return the data that
* was stored in the list.
*
* Must be O(n).
*
* @param data the data to be removed from the list
* @return the data that was removed
* @throws java.lang.IllegalArgumentException if data is null
* @throws java.util.NoSuchElementException if data is not found
*/
public T removeLastOccurrence(T data){
}
/**
* Returns an array representation of the linked list.
*
* Must be O(n) for all cases.
*
* @return the array of length size holding all of the data (not the
* nodes) in the list in the same order
*/
public T[] toArray(){
}
/**
* Returns the head node of the list.
*
* For grading purposes only. You shouldn't need to use this method since
* you have direct access to the variable.
*
* @return the node at the head of the list
*/
public CircularSinglyLinkedListNode getHead(){
// DO NOT MODIFY!
return head;
}
/**
* Returns the size of the list.
*
* For grading purposes only. You shouldn't need to use this method since
* you have direct access to the variable.
*
* @return the size of the list
*/
public int size(){
// DO NOT MODIFY!
return size;
}
}
 /** * Your implementation of a CircularSinglyLinkedList without a tail pointer.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!