SlideShare a Scribd company logo
1 of 10
Download to read offline
File: LinkedList.java
/**
* Defines a doubly-linked list class
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
/**
* Returns the value stored in the first node
* @precondition
* @return the value stored at node first
* @throws NoSuchElementException
*/
public T getFirst() throws NoSuchElementException {
return null;
}
/**
* Returns the value stored in the last node
* @precondition
* @return the value stored in the node last
* @throws NoSuchElementException
*/
public T getLast() throws NoSuchElementException {
return null;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
return null;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return -1;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return false;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return false;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition
*/
public void addFirst(T data) {
return;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition
*/
public void addLast(T data) {
return;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
return;
}
/**
* removes the element at the front of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeFirst() throws NoSuchElementException {
return;
}
/**
* removes the element at the end of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeLast() throws NoSuchElementException {
return;
}
/**
* removes the element referenced by the iterator
* @precondition
* @postcondition
* @throws NullPointerException
*/
public void removeIterator() throws NullPointerException {
}
/**
* places the iterator at the first node
* @postcondition
*/
public void positionIterator(){
}
/**
* Moves the iterator one node towards the last
* @precondition
* @postcondition
* @throws NullPointerException
*/
public void advanceIterator() throws NullPointerException {
}
/**
* Moves the iterator one node towards the first
* @precondition
* @postcondition
* @throws NullPointerException
*/
public void reverseIterator() throws NullPointerException {
}
/**** ADDITIONAL OPERATIONS ****/
/**
* Re-sets LinkedList to empty as if the
* default constructor had just been called
*/
public void clear() {
}
/**
* Converts the LinkedList to a String, with each value separated by a
* blank space. At the end of the String, place a new line character.
* @return the LinkedList as a String
*/
@Override
public String toString() {
return "n";
}
/**
* Determines whether the given Object is
* another LinkedList, containing
* the same data in the same order
* @param obj another Object
* @return whether there is equality
*/
@SuppressWarnings("unchecked") //good practice to remove warning here
@Override public boolean equals(Object obj) {
return false;
}
/**CHALLENGE METHODS*/
/**
* Moves all nodes in the list towards the end
* of the list the number of times specified
* Any node that falls off the end of the list as it
* moves forward will be placed the front of the list
* For example: [1, 2, 3, 4, 5], numMoves = 2 -> [4, 5, 1, 2 ,3]
* For example: [1, 2, 3, 4, 5], numMoves = 4 -> [2, 3, 4, 5, 1]
* For example: [1, 2, 3, 4, 5], numMoves = 7 -> [4, 5, 1, 2 ,3]
* @param numMoves the number of times to move each node.
* @precondition numMoves >= 0
* @postcondition iterator position unchanged (i.e. still referencing
* the same node in the list, regardless of new location of Node)
* @throws IllegalArgumentException when numMoves < 0
*/
public void spinList(int numMoves) throws IllegalArgumentException{
}
/**
* Splices together two LinkedLists to create a third List
* which contains alternating values from this list
* and the given parameter
* For example: [1,2,3] and [4,5,6] -> [1,4,2,5,3,6]
* For example: [1, 2, 3, 4] and [5, 6] -> [1, 5, 2, 6, 3, 4]
* For example: [1, 2] and [3, 4, 5, 6] -> [1, 3, 2, 4, 5, 6]
* @param list the second LinkedList
* @return a new LinkedList, which is the result of
* alternating this and list
* @postcondition this and list are unchanged
*/
public LinkedList altLists(LinkedList list) {
return null;
}
}
Created intlist: 12334 Created abclist: A B C Created emptyList: Created nullist: Created
intcopy: 1234 Created abcCopy: A B C Created emptycopy: Created nullcopy: intList.equals
(null): false intlist.equals (emptyList): false intlist.equals(abclist): false abclist.equals (intList):
false intList.equals (intList): true abclist.equals (abcList) : trued abcList.equals (abcCopy) : true
nullist.equals (nullcopy): true emptyList. equals (emptycopy): true emptyList.equals (nullist) :
true abcList.spinList (0): A B C abcList.spinList(1): C A B abcList.spinList(2): A B C
abcList.spinList(3): A B C intList.spinList(3): 2341 intList.spinList(5): 1234 emptyList. spinList
(1): nullist.spinList (1): Created list123: 123 Created list456: 456 list123.altLists(list456):
142536 Created list1234: 1234 Created list56: 56 list1234.altLists(list56): 152634 Created list12:
12 Created list3456: 3456 list12.altists(list3456): 132456 abcList.altLists (emptyList): A B C
abclist.altists(nullist): A B C
// Test spinlist abcList.spinList ( ); System.out.print ("abcList.spinList( ) : ");
abclist.displayList(); abcList.spinList(1); System.out.print ("abcList.spinList(1): ");
abcList.displaylist(); abcList.spinList(2); System.out.print("abcList.spinList(2): ");
abcList.displaylist(); abcList.spinList(3); System.out.print ("abcList.spinList(3): ");
abcList.displayList(); intList.spinList(3); System.out.print("intList.spinList(3): ");
intList.displaylist(); intList.spinList(5); System.out.print ("intList.spinList(5): ");
intList.displayList(); emptyList.spinList(1); System.out.print ("emptyList.spinList(1): ");
emptyList.displaylist(); nullList.spinList(1); System.out.print("nullList.spinList(1): ");
nullList.displayList(); // Test altLists LinkedList> list123 = new LinkedList >( new Integer [ ]
{1,2,3}); System.out.print("Created list123: "); list123.displayList(); LinkedList> list456 = new
LinkedList >( new Integer [ ] {4,5,6}); System.out.print("Created list456: ");
list456.displayList(); System.out.print("list123.altLists(list456): ");
list123.altLists(list456).displayList(); LinkedList> list1234 = new LinkedList >( new
Integer[]{1,2,3,4}); System.out.print("Created list1234: "); list1234.displayList();
2:Unit test all assigned methods 0/35 New constructors, equals(), spinList(), altList()
java.lang.NullPointerException
Step 1: Copy your LinkedList Copy your completed LinkedList class from Lab 3 into the
LinkedList. java file below. During this lab we will add more constructors, an equals method and
more challenging methods as listed below. Also inspect the LabProgram. java file and notice that
the main() method of the LabProgram copies and compares two linked lists. The main () method
also calls the more challenging methods. Use Develop mode to test your LinkedList iterator code
as you develop it. In Submit mode you will need to complete all lab steps to pass all automatic
tests. Step 2: Implement clear() Method clear() re-sets the LinkedList to empty as if the default
constructor had just been called. Step 3: Implement LinkedList(T[ ] array) Constructor
LinkedList ( T[] array) converts the given array into a LinkedList. public LinkedList (T[] array)
& } Step 4: Implement the copy constructor Constructor LinkedList (LinkedList T> original)
instantiates a new LinkedList by copying another List. public LinkedList (LinkedList original) {
} Step 5: Implement boolean equals(object o) Method equals() determines whether the given
object is another LinkedList, containing the same data in the same order, returning whether there
is equality. Step 6: Implement spinList(int numMoves) Method spinList (int numMoves) moves
all nodes in the list towards the end of the list the number of times specified. Any node that falls
off the end of the list as it moves forward will be placed at the front of the list. Ex: [A,B,C],
numMoves =1[C,A,B] Ex: [1,2,3,4], numMoves =3[2,3,4,1] Ex: [2,3,4,1], numMoves
=5[1,2,3,4] Step 7: Implement LinkedList T altLists (LinkedList T list) Method altLists() splices
together two LinkedLists to create a third List which contains alternating values from the original
list and the given parameter. Ex: [1,2,3] and [4,5,6][1,4,2,5,3,6] Ex: [1,2,3,4] and
[5,6][1,5,2,6,3,4]
LinkedList list56 = new LinkedList<>(new Integer[] {5,6}); System.out.print("Created list56: ");
list56.displayList(); System.out.print("list1234.altLists(list56): ");
list1234.altLists(list56).displayList(); LinkedList list12 = new LinkedList<>(new Integer[] {1,2
} ); System.out.print("Created list12: "); list12.displayList(); LinkedList list3456 = new
LinkedList<>(new Integer[] {3,4,5,6 }); System.out.print("Created list3456: ");
list3456.displayList(); System.out.print("list12.altLists(list3456): ");
list12.altLists(list3456).displayList(); System.out.print("abcList.altLists(emptyList): ");
abcList.altLists(emptyList).displayList(); System.out.print("abcList.altLists(nullList): ");
abcList.altLists(nullList).displayList(); LinkedList Integer > list5 = new LinkedList >( new
Integer [ ]{5,6}); System.out.print("Created list56: "); list56.displayList();
System.out.print("list1234.altLists(list56): "); list1234.altLists(list56).displayList(); LinkedList>
list12 = new LinkedList <>( new Integer[ ] {1,2}); System.out.print("Created list12: ");
list12.displayList(); LinkedList list3456 = new LinkedList<>(new Integer[ ]{3,4,5,6});
System.out.print ("Created list3456: "); list3456.displayList();
System.out.print("list12.altLists(list3456): "); list12.altLists(list3456).displayList();
System.out.print("abcList.altLists(emptyList): "); abcList.altLists (emptyList).displayList();
System.out.print("abcList.altLists(nullList): "); abcList.altLists(nullList).displayList(); }
lic class LabProgram T[{] public static void main(String[] args) { LabProgram lab = new
LabProgram(); // Make and display lists using array constructor LinkedList Integer > intList =
new LinkedList >( new Integer [ ] {1,2,3,4}); System.out.print("created intList: ");
intList.displaylist(); LinkedList abcList = new LinkedList<>(new String[] { "A", "B", "C" } );
System.out.print("created abcList: "); abclist.displaylist(); LinkedList String > emptyList = new
LinkedList langlerangle() ; System.out.print ("Created emptyList: "); emptyList.displaylist();
String[] array = new String[0];// Initialize with an empty array LinkedList String > nullList =
new LinkedList >( array ); System.out.print("Created nullList: "); nullList.displayList(); // Copy
all using copy constructor LinkedList < Integer > intCopy = new LinkedList > (intList);
System.out.print("Created intCopy: "); intCopy.displaylist(); LinkedList String > abcCopy =
new LinkedList > (abcList); System.out.print("created abcCopy: "); abcCopy.displayList();
LinkedList String > emptyCopy = new LinkedList > (emptyList); System.out.print("Created
emptyCopy: "); emptyCopy.displaylist(); LinkedList String > nullCopy = new LinkedList >
(nullList); System.out.print("Created nullCopy: "); nullCopy.displayList(); // Test equals
System.out.println("intlist.equals(null): " + intList.equals(null)); System.out.println
("intList.equals(emptyList): " + intList.equals(emptyList));
System.out.println("intList.equals(abcList): " + intlist.equals(abclist));
System.out.println("abclist.equals(intList): " + abclist.equals(intList));
System.out.println("intlist.equals(intList): " + intlist.equals(intList));
System.out.println("abclist.equals(abcCopy): " + abclist.equals(abcCopy));
System.out.println("nullList.equals(nullCopy): " + nullist.equals(nullCopy));
System.out.println("emptylist. equals(emptyCopy): " + emptyList.equals(emptyCopy));
System.out.println("emptyList.equals(nullList): " + emptyList.equals(nullList)); // Test spinList
abcList.spinList(0); System.out.print ("abcList.spinList( (0): "); abcList.displayList();

More Related Content

Similar to File LinkedList.java Defines a doubly-l.pdf

The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfmalavshah9013
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfannaelctronics
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfEricvtJFraserr
 
Complete in JavaCardApp.javapublic class CardApp { private.pdf
Complete in JavaCardApp.javapublic class CardApp {   private.pdfComplete in JavaCardApp.javapublic class CardApp {   private.pdf
Complete in JavaCardApp.javapublic class CardApp { private.pdfMAYANKBANSAL1981
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdfalmaniaeyewear
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfkingsandqueens3
 
How do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdfHow do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdffmac5
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docxKomlin1
 
Jhtp5 20 Datastructures
Jhtp5 20 DatastructuresJhtp5 20 Datastructures
Jhtp5 20 Datastructuresmartha leon
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdftesmondday29076
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfezonesolutions
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23HUST
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23HUST
 
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfHow do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfmail931892
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxcgraciela1
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfdeepak596396
 
Exception to indicate that Singly LinkedList is empty. .pdf
  Exception to indicate that Singly LinkedList is empty. .pdf  Exception to indicate that Singly LinkedList is empty. .pdf
Exception to indicate that Singly LinkedList is empty. .pdfaravlitraders2012
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfcontact41
 

Similar to File LinkedList.java Defines a doubly-l.pdf (20)

The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
Complete in JavaCardApp.javapublic class CardApp { private.pdf
Complete in JavaCardApp.javapublic class CardApp {   private.pdfComplete in JavaCardApp.javapublic class CardApp {   private.pdf
Complete in JavaCardApp.javapublic class CardApp { private.pdf
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
 
How do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdfHow do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdf
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 
Jhtp5 20 Datastructures
Jhtp5 20 DatastructuresJhtp5 20 Datastructures
Jhtp5 20 Datastructures
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdf
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23
 
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfHow do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docx
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdf
 
Exception to indicate that Singly LinkedList is empty. .pdf
  Exception to indicate that Singly LinkedList is empty. .pdf  Exception to indicate that Singly LinkedList is empty. .pdf
Exception to indicate that Singly LinkedList is empty. .pdf
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
 

More from Conint29

Given BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfGiven BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfConint29
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdfConint29
 
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover  Back in July 30th 1971, the c.pdfDomain Description for the Lunar Rover  Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdfConint29
 
Design a PIC based wearable device that keeps a tract of the activit.pdf
Design a PIC based wearable device that keeps a tract of the activit.pdfDesign a PIC based wearable device that keeps a tract of the activit.pdf
Design a PIC based wearable device that keeps a tract of the activit.pdfConint29
 
Describe any five (5) advantages of computer networkingList any (5) ex.pdf
Describe any five (5) advantages of computer networkingList any (5) ex.pdfDescribe any five (5) advantages of computer networkingList any (5) ex.pdf
Describe any five (5) advantages of computer networkingList any (5) ex.pdfConint29
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfConint29
 
I am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfI am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfConint29
 
how to Create a PDF holding all of your database data from Module 8..pdf
how to Create a PDF holding all of your database data from Module 8..pdfhow to Create a PDF holding all of your database data from Module 8..pdf
how to Create a PDF holding all of your database data from Module 8..pdfConint29
 
How do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdfHow do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdfConint29
 
Here I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdfHere I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdfConint29
 
Exchange Rate Determination Theory OvershootingExchange rate over.pdf
Exchange Rate Determination Theory OvershootingExchange rate over.pdfExchange Rate Determination Theory OvershootingExchange rate over.pdf
Exchange Rate Determination Theory OvershootingExchange rate over.pdfConint29
 
Encapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdfEncapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdfConint29
 
Hello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdfHello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdfConint29
 

More from Conint29 (13)

Given BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfGiven BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdf
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdf
 
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover  Back in July 30th 1971, the c.pdfDomain Description for the Lunar Rover  Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdf
 
Design a PIC based wearable device that keeps a tract of the activit.pdf
Design a PIC based wearable device that keeps a tract of the activit.pdfDesign a PIC based wearable device that keeps a tract of the activit.pdf
Design a PIC based wearable device that keeps a tract of the activit.pdf
 
Describe any five (5) advantages of computer networkingList any (5) ex.pdf
Describe any five (5) advantages of computer networkingList any (5) ex.pdfDescribe any five (5) advantages of computer networkingList any (5) ex.pdf
Describe any five (5) advantages of computer networkingList any (5) ex.pdf
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
I am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfI am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdf
 
how to Create a PDF holding all of your database data from Module 8..pdf
how to Create a PDF holding all of your database data from Module 8..pdfhow to Create a PDF holding all of your database data from Module 8..pdf
how to Create a PDF holding all of your database data from Module 8..pdf
 
How do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdfHow do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdf
 
Here I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdfHere I have a function in my code that checks the separation of airc.pdf
Here I have a function in my code that checks the separation of airc.pdf
 
Exchange Rate Determination Theory OvershootingExchange rate over.pdf
Exchange Rate Determination Theory OvershootingExchange rate over.pdfExchange Rate Determination Theory OvershootingExchange rate over.pdf
Exchange Rate Determination Theory OvershootingExchange rate over.pdf
 
Encapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdfEncapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdf
 
Hello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdfHello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdf
 

Recently uploaded

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Recently uploaded (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

File LinkedList.java Defines a doubly-l.pdf

  • 1. File: LinkedList.java /** * Defines a doubly-linked list class */ import java.util.NoSuchElementException; public class LinkedList { private class Node { private T data; private Node next; private Node prev; public Node(T data) { this.data = data; this.next = null; this.prev = null; } } private int length; private Node first; private Node last; private Node iterator; /**** CONSTRUCTORS ****/ /** * Instantiates a new LinkedList with default values * @postcondition */
  • 2. public LinkedList() { } /** * Converts the given array into a LinkedList * @param array the array of values to insert into this LinkedList * @postcondition */ public LinkedList(T[] array) { } /** * Instantiates a new LinkedList by copying another List * @param original the LinkedList to copy * @postcondition a new List object, which is an identical, * but separate, copy of the LinkedList original */ public LinkedList(LinkedList original) { } /**** ACCESSORS ****/ /** * Returns the value stored in the first node * @precondition * @return the value stored at node first * @throws NoSuchElementException */ public T getFirst() throws NoSuchElementException { return null; } /** * Returns the value stored in the last node * @precondition * @return the value stored in the node last * @throws NoSuchElementException */ public T getLast() throws NoSuchElementException { return null; }
  • 3. /** * Returns the data stored in the iterator node * @precondition * @return the data stored in the iterator node * @throw NullPointerException */ public T getIterator() throws NullPointerException { return null; } /** * Returns the current length of the LinkedList * @return the length of the LinkedList from 0 to n */ public int getLength() { return -1; } /** * Returns whether the LinkedList is currently empty * @return whether the LinkedList is empty */ public boolean isEmpty() { return false; } /** * Returns whether the iterator is offEnd, i.e. null * @return whether the iterator is null */ public boolean offEnd() { return false; } /**** MUTATORS ****/ /** * Creates a new first element * @param data the data to insert at the front of the LinkedList * @postcondition */
  • 4. public void addFirst(T data) { return; } /** * Creates a new last element * @param data the data to insert at the end of the LinkedList * @postcondition */ public void addLast(T data) { return; } /** * Inserts a new element after the iterator * @param data the data to insert * @precondition * @throws NullPointerException */ public void addIterator(T data) throws NullPointerException{ return; } /** * removes the element at the front of the LinkedList * @precondition * @postcondition * @throws NoSuchElementException */ public void removeFirst() throws NoSuchElementException { return; } /** * removes the element at the end of the LinkedList * @precondition * @postcondition * @throws NoSuchElementException */ public void removeLast() throws NoSuchElementException {
  • 5. return; } /** * removes the element referenced by the iterator * @precondition * @postcondition * @throws NullPointerException */ public void removeIterator() throws NullPointerException { } /** * places the iterator at the first node * @postcondition */ public void positionIterator(){ } /** * Moves the iterator one node towards the last * @precondition * @postcondition * @throws NullPointerException */ public void advanceIterator() throws NullPointerException { } /** * Moves the iterator one node towards the first * @precondition * @postcondition * @throws NullPointerException */ public void reverseIterator() throws NullPointerException { } /**** ADDITIONAL OPERATIONS ****/ /** * Re-sets LinkedList to empty as if the * default constructor had just been called
  • 6. */ public void clear() { } /** * Converts the LinkedList to a String, with each value separated by a * blank space. At the end of the String, place a new line character. * @return the LinkedList as a String */ @Override public String toString() { return "n"; } /** * Determines whether the given Object is * another LinkedList, containing * the same data in the same order * @param obj another Object * @return whether there is equality */ @SuppressWarnings("unchecked") //good practice to remove warning here @Override public boolean equals(Object obj) { return false; } /**CHALLENGE METHODS*/ /** * Moves all nodes in the list towards the end * of the list the number of times specified * Any node that falls off the end of the list as it * moves forward will be placed the front of the list * For example: [1, 2, 3, 4, 5], numMoves = 2 -> [4, 5, 1, 2 ,3] * For example: [1, 2, 3, 4, 5], numMoves = 4 -> [2, 3, 4, 5, 1] * For example: [1, 2, 3, 4, 5], numMoves = 7 -> [4, 5, 1, 2 ,3] * @param numMoves the number of times to move each node. * @precondition numMoves >= 0 * @postcondition iterator position unchanged (i.e. still referencing * the same node in the list, regardless of new location of Node)
  • 7. * @throws IllegalArgumentException when numMoves < 0 */ public void spinList(int numMoves) throws IllegalArgumentException{ } /** * Splices together two LinkedLists to create a third List * which contains alternating values from this list * and the given parameter * For example: [1,2,3] and [4,5,6] -> [1,4,2,5,3,6] * For example: [1, 2, 3, 4] and [5, 6] -> [1, 5, 2, 6, 3, 4] * For example: [1, 2] and [3, 4, 5, 6] -> [1, 3, 2, 4, 5, 6] * @param list the second LinkedList * @return a new LinkedList, which is the result of * alternating this and list * @postcondition this and list are unchanged */ public LinkedList altLists(LinkedList list) { return null; } } Created intlist: 12334 Created abclist: A B C Created emptyList: Created nullist: Created intcopy: 1234 Created abcCopy: A B C Created emptycopy: Created nullcopy: intList.equals (null): false intlist.equals (emptyList): false intlist.equals(abclist): false abclist.equals (intList): false intList.equals (intList): true abclist.equals (abcList) : trued abcList.equals (abcCopy) : true nullist.equals (nullcopy): true emptyList. equals (emptycopy): true emptyList.equals (nullist) : true abcList.spinList (0): A B C abcList.spinList(1): C A B abcList.spinList(2): A B C abcList.spinList(3): A B C intList.spinList(3): 2341 intList.spinList(5): 1234 emptyList. spinList (1): nullist.spinList (1): Created list123: 123 Created list456: 456 list123.altLists(list456): 142536 Created list1234: 1234 Created list56: 56 list1234.altLists(list56): 152634 Created list12: 12 Created list3456: 3456 list12.altists(list3456): 132456 abcList.altLists (emptyList): A B C abclist.altists(nullist): A B C
  • 8. // Test spinlist abcList.spinList ( ); System.out.print ("abcList.spinList( ) : "); abclist.displayList(); abcList.spinList(1); System.out.print ("abcList.spinList(1): "); abcList.displaylist(); abcList.spinList(2); System.out.print("abcList.spinList(2): "); abcList.displaylist(); abcList.spinList(3); System.out.print ("abcList.spinList(3): "); abcList.displayList(); intList.spinList(3); System.out.print("intList.spinList(3): "); intList.displaylist(); intList.spinList(5); System.out.print ("intList.spinList(5): "); intList.displayList(); emptyList.spinList(1); System.out.print ("emptyList.spinList(1): "); emptyList.displaylist(); nullList.spinList(1); System.out.print("nullList.spinList(1): "); nullList.displayList(); // Test altLists LinkedList> list123 = new LinkedList >( new Integer [ ] {1,2,3}); System.out.print("Created list123: "); list123.displayList(); LinkedList> list456 = new LinkedList >( new Integer [ ] {4,5,6}); System.out.print("Created list456: "); list456.displayList(); System.out.print("list123.altLists(list456): "); list123.altLists(list456).displayList(); LinkedList> list1234 = new LinkedList >( new Integer[]{1,2,3,4}); System.out.print("Created list1234: "); list1234.displayList(); 2:Unit test all assigned methods 0/35 New constructors, equals(), spinList(), altList() java.lang.NullPointerException Step 1: Copy your LinkedList Copy your completed LinkedList class from Lab 3 into the LinkedList. java file below. During this lab we will add more constructors, an equals method and more challenging methods as listed below. Also inspect the LabProgram. java file and notice that the main() method of the LabProgram copies and compares two linked lists. The main () method also calls the more challenging methods. Use Develop mode to test your LinkedList iterator code as you develop it. In Submit mode you will need to complete all lab steps to pass all automatic tests. Step 2: Implement clear() Method clear() re-sets the LinkedList to empty as if the default constructor had just been called. Step 3: Implement LinkedList(T[ ] array) Constructor LinkedList ( T[] array) converts the given array into a LinkedList. public LinkedList (T[] array) & } Step 4: Implement the copy constructor Constructor LinkedList (LinkedList T> original) instantiates a new LinkedList by copying another List. public LinkedList (LinkedList original) {
  • 9. } Step 5: Implement boolean equals(object o) Method equals() determines whether the given object is another LinkedList, containing the same data in the same order, returning whether there is equality. Step 6: Implement spinList(int numMoves) Method spinList (int numMoves) moves all nodes in the list towards the end of the list the number of times specified. Any node that falls off the end of the list as it moves forward will be placed at the front of the list. Ex: [A,B,C], numMoves =1[C,A,B] Ex: [1,2,3,4], numMoves =3[2,3,4,1] Ex: [2,3,4,1], numMoves =5[1,2,3,4] Step 7: Implement LinkedList T altLists (LinkedList T list) Method altLists() splices together two LinkedLists to create a third List which contains alternating values from the original list and the given parameter. Ex: [1,2,3] and [4,5,6][1,4,2,5,3,6] Ex: [1,2,3,4] and [5,6][1,5,2,6,3,4] LinkedList list56 = new LinkedList<>(new Integer[] {5,6}); System.out.print("Created list56: "); list56.displayList(); System.out.print("list1234.altLists(list56): "); list1234.altLists(list56).displayList(); LinkedList list12 = new LinkedList<>(new Integer[] {1,2 } ); System.out.print("Created list12: "); list12.displayList(); LinkedList list3456 = new LinkedList<>(new Integer[] {3,4,5,6 }); System.out.print("Created list3456: "); list3456.displayList(); System.out.print("list12.altLists(list3456): "); list12.altLists(list3456).displayList(); System.out.print("abcList.altLists(emptyList): "); abcList.altLists(emptyList).displayList(); System.out.print("abcList.altLists(nullList): "); abcList.altLists(nullList).displayList(); LinkedList Integer > list5 = new LinkedList >( new Integer [ ]{5,6}); System.out.print("Created list56: "); list56.displayList(); System.out.print("list1234.altLists(list56): "); list1234.altLists(list56).displayList(); LinkedList> list12 = new LinkedList <>( new Integer[ ] {1,2}); System.out.print("Created list12: "); list12.displayList(); LinkedList list3456 = new LinkedList<>(new Integer[ ]{3,4,5,6}); System.out.print ("Created list3456: "); list3456.displayList(); System.out.print("list12.altLists(list3456): "); list12.altLists(list3456).displayList(); System.out.print("abcList.altLists(emptyList): "); abcList.altLists (emptyList).displayList(); System.out.print("abcList.altLists(nullList): "); abcList.altLists(nullList).displayList(); } lic class LabProgram T[{] public static void main(String[] args) { LabProgram lab = new LabProgram(); // Make and display lists using array constructor LinkedList Integer > intList = new LinkedList >( new Integer [ ] {1,2,3,4}); System.out.print("created intList: "); intList.displaylist(); LinkedList abcList = new LinkedList<>(new String[] { "A", "B", "C" } ); System.out.print("created abcList: "); abclist.displaylist(); LinkedList String > emptyList = new LinkedList langlerangle() ; System.out.print ("Created emptyList: "); emptyList.displaylist(); String[] array = new String[0];// Initialize with an empty array LinkedList String > nullList =
  • 10. new LinkedList >( array ); System.out.print("Created nullList: "); nullList.displayList(); // Copy all using copy constructor LinkedList < Integer > intCopy = new LinkedList > (intList); System.out.print("Created intCopy: "); intCopy.displaylist(); LinkedList String > abcCopy = new LinkedList > (abcList); System.out.print("created abcCopy: "); abcCopy.displayList(); LinkedList String > emptyCopy = new LinkedList > (emptyList); System.out.print("Created emptyCopy: "); emptyCopy.displaylist(); LinkedList String > nullCopy = new LinkedList > (nullList); System.out.print("Created nullCopy: "); nullCopy.displayList(); // Test equals System.out.println("intlist.equals(null): " + intList.equals(null)); System.out.println ("intList.equals(emptyList): " + intList.equals(emptyList)); System.out.println("intList.equals(abcList): " + intlist.equals(abclist)); System.out.println("abclist.equals(intList): " + abclist.equals(intList)); System.out.println("intlist.equals(intList): " + intlist.equals(intList)); System.out.println("abclist.equals(abcCopy): " + abclist.equals(abcCopy)); System.out.println("nullList.equals(nullCopy): " + nullist.equals(nullCopy)); System.out.println("emptylist. equals(emptyCopy): " + emptyList.equals(emptyCopy)); System.out.println("emptyList.equals(nullList): " + emptyList.equals(nullList)); // Test spinList abcList.spinList(0); System.out.print ("abcList.spinList( (0): "); abcList.displayList();