Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1 : Java implementation of a Linked List For this part, you will be provided a set of skeleton classes for you to implement
Part : Java implementation of a Linked List
For this part, you will be provided a set of skeleton classes for you to implement a singly linked list of
type int. You will also be provided a minimal set of test cases. You are encouraged to augment the test
suite.
Import the eclipse project Assignmentzip into your workspace. The package includes a complete Node
class as well as a test suite MyLinkedListTest. A skeleton MyLinkedList class is provided with the
following methods that need to be implemented:
Points Method
public MyLinkedList constructor
public void addint data
public void addint data
public void addMyLinkedList l
public int getint index
public void removeint data
public boolean containsint needle
public static boolean equalsMyLinkedList l MyLinkedList l
public boolean equalsMyLinkedList l
public boolean equalsObject o
public boolean isEmpty
public int findMinIterative
public int findMinRecursive
public int size
public String toString
Total
package camcgill.cccsassignment;
public class Node
private int data;
private Node next;
public Nodeint data
this.data data;
this.next null;
public int getData
return data;
public Node getNext
return next;
public void setDataint data
this.data data;
public void setNextNode next
this.next next;
Answers to this part's questions
Which findMin implementation is faster and why?
Which findMin implementation has less lines of code and why?
public class MyLinkedList
private Node head;
private int size;
Constructor that initializes an empty
linked list
BigO:
public MyLinkedList
You complete me
Add a single element to the list
BigO:
@param data The int to be added at the end of the list
public void addint data
You complete me
Add an array of elements to the end of the list
BigO:
@param data The array of elements to be added
public void addint data
You complete me
Add a list of elements to the end of the list
BigO:
@param data The list of elements to be added
public void addMyLinkedList l
You complete me
Retrieve the element at the given index
BigO:
@param index The position of the element starting at zero
@return The value contained in the node at the index
public int getint index
You complete me
Remove every instance of data in the list
BigO:
@param data The data to be removed from the list
public void removeint data
You complete me
Determines whether the needle exists in the list
BigO:
@param needle The value you are looking for
@return True if needle is found in the list. False otherwise
public boolean containsint needle
You complete me
Check whether two lists have the same values
BigO:
@param l The first list
@param l The second list
@return True if the lists contain the same elements in the same order. False otherwise
public static boolean equalsMyLinkedList l MyLinkedList l
You complete me
Check whether this list is equal to the list provided as input
BigO:
@param l The list to check
@return True if the lists contain the same elements in the same order. False otherwise
public boolean equalsMyLinkedList l
You complete me
Check whether this list is equal to the list provided as input
BigO:
@param o The object to check
@return True if the lists contain the same elements in the same order. False otherwise
@Override
public boolean equalsObject o
You complete me
Returns true when the list is empty and false otherwise
BigO:
@return True if the list is empty
public boolean isEmpty
You complete me
Find the minimum of a list in an iterative manner
BigO:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started