SlideShare a Scribd company logo
Linked List
Objective: The purpose of this exercise is to create a Linked List data structure that mimics the
behavior of the Java Standard Library Version (Java API). The outcomes/results of using the
library features should be identical with your own version (My API). However, the underlying
implementation should follow with the descriptions listed below.
Instructions : Create the following Linked List Data Structure with the given description below in
your utils package and use "for loops" for your repetitive tasks.
Where to find starter code in my-api
package.class : utils.LinkedList
package.class : tests.console.week04.LinkedListTest
Where to find your JUNIT test in my-api
package.class : tests.junit.LinkedListJUnitTest
Nested Class that has to be added to LinkedList class
package.class : utils.LinkedList.Node
Task Check List
ONLY "for" loops should be used within the data structure class. There is an automatic 30%
deduction, if other loops are used.
The names of identifiers MUST match the names listed in the description below. Deductions
otherwise.
Complete coding Assignment in your "my-api" GitHub Repository. You will not be graded
otherwise and will receive a 0, if not uploaded there.
Run JUNIT TEST and take a SNAPSHOT of results. Upload PDF of snapshot of your JUnitTest
results to Canvas.
Description
The internal structure of the Linked List is a doubly linked Node data structure and should have
at a minimum the following specifications:
data fields: The data fields to declare are private and you will keep track of the size of the list with
the variable size and the start of the list with the reference variable data.
first is a reference variable for the first Node<E> in the list.
last is a reference variable for the last Node<E> in the list.
size keeps track of the number of nodes in the list of type int. This will allow you to know the
current size of the list without having to traversing the list.
constructors: The overloaded constructors will initialize the data fields size and data.
A constructor that is a default constructor initializes the starting node location first and size to a
zero equivalent, that is, constructs an empty list.
methods: methods that manages the behavior of the linked nodes.
Together, the methods below give the illusion of a index or countable location. Implement these
methods within your generic Linked List class.
Method
Description
Header
public boolean add(E item)
public void add(int index, E item)
public void append( E item)
private void checkIndex(int index)
public boolean contains(E item)
public void clear()
private E detach(int index)
public E get(int index)
public int indexOf(E item)
private void insertBefore(int index, E item)
public boolean isEmpty()
private Node<E> node(int index)
public E remove(int index)
public boolean remove(E item)
public E set(int index, E item)
public int size()
public String toString()
Node Data Structure
The generic Linked List class includes a static Node class as a nested class, i.e. a static inner
class within the Linked List class.
inner class: class inside the body of another class.
Note: This private class does not require access to instance members of the outer class, so it is
declared static. This means that the node object wont be coupled to the outer class object, thus
will be more optimal since it wont require heap/stack memory.
data fields:
data : hold the data stored in each node as is of type E.
next : stores the location of the next node in the list.
prev : stores the location of the previous node in the list.
constructor:
A constructor that receives parameters for data, and prev and calls the second constructor.
public Node(Node<E> prev, E data)
A constructor that receives parameters for data, next and prev.
public Node(Node<E> prev, E data, Node<E> next)
Method Description Header
add(item)
uses the append method and
ensures that there is enough
spaces to store each element in
the list. Also updates the
number of elements in the list
by one. This method returns
true, if the data was added
successfully.
public boolean add(E item)
add(index, item)
inserts elements at a given
location in the list, shifting
subsequent elements to the
right. Uses the append and
insertBefore methods to assist
with adding items to the front,
back and middle of the list.
Updates the number of
elements in the list by one.
public void add(int index, E
item)
append(item)
appends elements to the end of
the list, but does not update the
number of elements. This is a
private helper method.
public void append( E item)
checkIndex(index)
checks if the given index is
valid. Validation means that you
cannot access indexes where
elements have not been placed.
Throws an
IndexOutOfBoundsException
, if invalid. This is a private
helper method.
private void checkIndex(int
index)
contains(item)
searches for a specific item
within the linked structure and
returns true, if the item is in the
list.
public boolean contains(E
item)
clear()
clears list of all elements,
returns size back to zero.
public void clear()
detach(index)
detaches the node at the
specified index from list and
returns the deleted element, but
does not reduce the size of the
list. This is a private helper
method.
private E detach(int index)
get(index)
returns the item at the specified
position in the list. This method
first checks if the index
requested is valid.
public E get(int index)
indexOf(item)
searches for a specific item
within the linked structure and
returns the first occurrence (i.e.
index location) in the list,
otherwise returns -1, if NOT
found.
public int indexOf(E item)
insertBefore(index, item)
inserts an item before the non-
null node at the specified index
in the list. Traverses the list to
find this node. This method also
checks for insertions at the start
and end of the list, as well as
when empty. This is a private
helper method.
private void insertBefore(int
index, E item)
isEmpty()
returns true, if the list is empty,
i.e., the list contains no
elements.
public boolean isEmpty()
node(index)
returns a reference to the node
at the given position in the list.
This node traverses the list in
two directions from front to
middle and back to middle. This
is a private helper method.
private Node<E> node(int
index)
remove(index)
removes the item at the given
position in the list for a valid
index. Checks for valid index
before it proceeds with removal.
Shifts subsequent elements to
the left and returns the item
removed. The number of
elements in the list is reduced
by one.
public E remove(int index)
remove(item)
removes the first occurrence of
the specified item from the list,
if present. Shifts subsequent
elements to the left and returns
true, if the item is removed. The
number of elements in the list is
reduced by one.
public boolean remove(E item)
set(index, item)
replaces the item at the
specified position with the one
passed. This method checks if
the index requested is valid
before it does the replacement
and returns the replaced item.
public E set(int index, E item)
size()
returns the number of elements
in the list.
public int size()
toString()
displays the contents of the list
according to the same format at
shown in the Java API.
public String toString()

More Related Content

Similar to Linked List Objective The purpose of this exercise is to cr.pdf

1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
Nguync91368
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
swajahatr
 
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
xlynettalampleyxc
 
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
Komlin1
 
There are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdfThere are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdf
aamousnowov
 
Built-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdfBuilt-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdf
alivaisi1
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
SarthakSrivastava70
 
Seo Expert course in Pakistan
Seo Expert course in PakistanSeo Expert course in Pakistan
Seo Expert course in Pakistan
ssuserb2c86f
 
Linked list (java platform se 8 )
Linked list (java platform se 8 )Linked list (java platform se 8 )
Linked list (java platform se 8 )
charan kumar
 
DSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdfDSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdf
Bharati Vidyapeeth COE, Navi Mumbai
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
Muthukumaran Subramanian
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
Nivegeetha
 
Part B- Implementing a Sorted Linked list The class declarations has b.pdf
Part B- Implementing a Sorted Linked list The class declarations has b.pdfPart B- Implementing a Sorted Linked list The class declarations has b.pdf
Part B- Implementing a Sorted Linked list The class declarations has b.pdf
info571050
 
singly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malavsingly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malav
Rohit malav
 
Java.util
Java.utilJava.util
Java.util
Ramakrishna kapa
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
Youssef Elsalhawy
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
ssuseredfbe9
 
computer notes - Linked list inside computer memory
computer notes - Linked list inside computer memorycomputer notes - Linked list inside computer memory
computer notes - Linked list inside computer memoryecomputernotes
 

Similar to Linked List Objective The purpose of this exercise is to cr.pdf (20)

List data structure
List data structure List data structure
List data structure
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.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
 
There are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdfThere are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdf
 
Built-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdfBuilt-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdf
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
 
Seo Expert course in Pakistan
Seo Expert course in PakistanSeo Expert course in Pakistan
Seo Expert course in Pakistan
 
Linked list (java platform se 8 )
Linked list (java platform se 8 )Linked list (java platform se 8 )
Linked list (java platform se 8 )
 
DSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdfDSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdf
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 
Advanced core java
Advanced core javaAdvanced core java
Advanced core java
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
Part B- Implementing a Sorted Linked list The class declarations has b.pdf
Part B- Implementing a Sorted Linked list The class declarations has b.pdfPart B- Implementing a Sorted Linked list The class declarations has b.pdf
Part B- Implementing a Sorted Linked list The class declarations has b.pdf
 
singly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malavsingly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malav
 
Java.util
Java.utilJava.util
Java.util
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 
computer notes - Linked list inside computer memory
computer notes - Linked list inside computer memorycomputer notes - Linked list inside computer memory
computer notes - Linked list inside computer memory
 

More from adityacomputers001

Lord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdf
Lord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdfLord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdf
Lord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdf
adityacomputers001
 
Los equipos pueden fallar debido a las tareas que los miembr.pdf
Los equipos pueden fallar debido a las tareas que los miembr.pdfLos equipos pueden fallar debido a las tareas que los miembr.pdf
Los equipos pueden fallar debido a las tareas que los miembr.pdf
adityacomputers001
 
Los efectos de red son Opcin multiple aumentos en el val.pdf
Los efectos de red son  Opcin multiple  aumentos en el val.pdfLos efectos de red son  Opcin multiple  aumentos en el val.pdf
Los efectos de red son Opcin multiple aumentos en el val.pdf
adityacomputers001
 
Los escarabajos vienen en una amplia variedad de formas hb.pdf
Los escarabajos vienen en una amplia variedad de formas hb.pdfLos escarabajos vienen en una amplia variedad de formas hb.pdf
Los escarabajos vienen en una amplia variedad de formas hb.pdf
adityacomputers001
 
Los astrnomos nunca observarn directamente los primeros mi.pdf
Los astrnomos nunca observarn directamente los primeros mi.pdfLos astrnomos nunca observarn directamente los primeros mi.pdf
Los astrnomos nunca observarn directamente los primeros mi.pdf
adityacomputers001
 
Los auditores a menudo ganan honorarios considerables de una.pdf
Los auditores a menudo ganan honorarios considerables de una.pdfLos auditores a menudo ganan honorarios considerables de una.pdf
Los auditores a menudo ganan honorarios considerables de una.pdf
adityacomputers001
 
Los atajos cognitivos que influyen en la forma en que las pe.pdf
Los atajos cognitivos que influyen en la forma en que las pe.pdfLos atajos cognitivos que influyen en la forma en que las pe.pdf
Los atajos cognitivos que influyen en la forma en que las pe.pdf
adityacomputers001
 
Los animales que se clasifican fcilmente en phyla existente.pdf
Los animales que se clasifican fcilmente en phyla existente.pdfLos animales que se clasifican fcilmente en phyla existente.pdf
Los animales que se clasifican fcilmente en phyla existente.pdf
adityacomputers001
 
Lophotrochozoans have traits that are present in some but no.pdf
Lophotrochozoans have traits that are present in some but no.pdfLophotrochozoans have traits that are present in some but no.pdf
Lophotrochozoans have traits that are present in some but no.pdf
adityacomputers001
 
Looking at the equation and figure below write a User Defin.pdf
Looking at the equation and figure below write a User Defin.pdfLooking at the equation and figure below write a User Defin.pdf
Looking at the equation and figure below write a User Defin.pdf
adityacomputers001
 
Logistics Consultants Inc LCi provides various logistics .pdf
Logistics Consultants Inc LCi provides various logistics .pdfLogistics Consultants Inc LCi provides various logistics .pdf
Logistics Consultants Inc LCi provides various logistics .pdf
adityacomputers001
 
logical description of the primary joints up to 2 within .pdf
logical description of the primary joints up to 2 within .pdflogical description of the primary joints up to 2 within .pdf
logical description of the primary joints up to 2 within .pdf
adityacomputers001
 
logistic modelFirst order ordinary differential equations .pdf
logistic modelFirst order ordinary differential equations  .pdflogistic modelFirst order ordinary differential equations  .pdf
logistic modelFirst order ordinary differential equations .pdf
adityacomputers001
 
Lincoln and the Global Economy_posted under Week 5 Instruct.pdf
Lincoln and the Global Economy_posted under Week 5 Instruct.pdfLincoln and the Global Economy_posted under Week 5 Instruct.pdf
Lincoln and the Global Economy_posted under Week 5 Instruct.pdf
adityacomputers001
 
Local state and national agencies such as the Center for D.pdf
Local state and national agencies such as the Center for D.pdfLocal state and national agencies such as the Center for D.pdf
Local state and national agencies such as the Center for D.pdf
adityacomputers001
 
LO 39 Explain the importance of gene expression regulation .pdf
LO 39 Explain the importance of gene expression regulation .pdfLO 39 Explain the importance of gene expression regulation .pdf
LO 39 Explain the importance of gene expression regulation .pdf
adityacomputers001
 
LO36 Explain why the genetic code is degenerate Which of the.pdf
LO36 Explain why the genetic code is degenerate Which of the.pdfLO36 Explain why the genetic code is degenerate Which of the.pdf
LO36 Explain why the genetic code is degenerate Which of the.pdf
adityacomputers001
 
Lo ms probable es que una empresa que tiene una ________ .pdf
Lo ms probable es que una empresa que tiene una ________ .pdfLo ms probable es que una empresa que tiene una ________ .pdf
Lo ms probable es que una empresa que tiene una ________ .pdf
adityacomputers001
 
Load the German Credit data using the following code import.pdf
Load the German Credit data using the following code import.pdfLoad the German Credit data using the following code import.pdf
Load the German Credit data using the following code import.pdf
adityacomputers001
 
LO49 Explain how expression of related genes can be coordina.pdf
LO49 Explain how expression of related genes can be coordina.pdfLO49 Explain how expression of related genes can be coordina.pdf
LO49 Explain how expression of related genes can be coordina.pdf
adityacomputers001
 

More from adityacomputers001 (20)

Lord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdf
Lord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdfLord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdf
Lord Esher declar en Willis v Baddeley 1892 2 QB 324 dec.pdf
 
Los equipos pueden fallar debido a las tareas que los miembr.pdf
Los equipos pueden fallar debido a las tareas que los miembr.pdfLos equipos pueden fallar debido a las tareas que los miembr.pdf
Los equipos pueden fallar debido a las tareas que los miembr.pdf
 
Los efectos de red son Opcin multiple aumentos en el val.pdf
Los efectos de red son  Opcin multiple  aumentos en el val.pdfLos efectos de red son  Opcin multiple  aumentos en el val.pdf
Los efectos de red son Opcin multiple aumentos en el val.pdf
 
Los escarabajos vienen en una amplia variedad de formas hb.pdf
Los escarabajos vienen en una amplia variedad de formas hb.pdfLos escarabajos vienen en una amplia variedad de formas hb.pdf
Los escarabajos vienen en una amplia variedad de formas hb.pdf
 
Los astrnomos nunca observarn directamente los primeros mi.pdf
Los astrnomos nunca observarn directamente los primeros mi.pdfLos astrnomos nunca observarn directamente los primeros mi.pdf
Los astrnomos nunca observarn directamente los primeros mi.pdf
 
Los auditores a menudo ganan honorarios considerables de una.pdf
Los auditores a menudo ganan honorarios considerables de una.pdfLos auditores a menudo ganan honorarios considerables de una.pdf
Los auditores a menudo ganan honorarios considerables de una.pdf
 
Los atajos cognitivos que influyen en la forma en que las pe.pdf
Los atajos cognitivos que influyen en la forma en que las pe.pdfLos atajos cognitivos que influyen en la forma en que las pe.pdf
Los atajos cognitivos que influyen en la forma en que las pe.pdf
 
Los animales que se clasifican fcilmente en phyla existente.pdf
Los animales que se clasifican fcilmente en phyla existente.pdfLos animales que se clasifican fcilmente en phyla existente.pdf
Los animales que se clasifican fcilmente en phyla existente.pdf
 
Lophotrochozoans have traits that are present in some but no.pdf
Lophotrochozoans have traits that are present in some but no.pdfLophotrochozoans have traits that are present in some but no.pdf
Lophotrochozoans have traits that are present in some but no.pdf
 
Looking at the equation and figure below write a User Defin.pdf
Looking at the equation and figure below write a User Defin.pdfLooking at the equation and figure below write a User Defin.pdf
Looking at the equation and figure below write a User Defin.pdf
 
Logistics Consultants Inc LCi provides various logistics .pdf
Logistics Consultants Inc LCi provides various logistics .pdfLogistics Consultants Inc LCi provides various logistics .pdf
Logistics Consultants Inc LCi provides various logistics .pdf
 
logical description of the primary joints up to 2 within .pdf
logical description of the primary joints up to 2 within .pdflogical description of the primary joints up to 2 within .pdf
logical description of the primary joints up to 2 within .pdf
 
logistic modelFirst order ordinary differential equations .pdf
logistic modelFirst order ordinary differential equations  .pdflogistic modelFirst order ordinary differential equations  .pdf
logistic modelFirst order ordinary differential equations .pdf
 
Lincoln and the Global Economy_posted under Week 5 Instruct.pdf
Lincoln and the Global Economy_posted under Week 5 Instruct.pdfLincoln and the Global Economy_posted under Week 5 Instruct.pdf
Lincoln and the Global Economy_posted under Week 5 Instruct.pdf
 
Local state and national agencies such as the Center for D.pdf
Local state and national agencies such as the Center for D.pdfLocal state and national agencies such as the Center for D.pdf
Local state and national agencies such as the Center for D.pdf
 
LO 39 Explain the importance of gene expression regulation .pdf
LO 39 Explain the importance of gene expression regulation .pdfLO 39 Explain the importance of gene expression regulation .pdf
LO 39 Explain the importance of gene expression regulation .pdf
 
LO36 Explain why the genetic code is degenerate Which of the.pdf
LO36 Explain why the genetic code is degenerate Which of the.pdfLO36 Explain why the genetic code is degenerate Which of the.pdf
LO36 Explain why the genetic code is degenerate Which of the.pdf
 
Lo ms probable es que una empresa que tiene una ________ .pdf
Lo ms probable es que una empresa que tiene una ________ .pdfLo ms probable es que una empresa que tiene una ________ .pdf
Lo ms probable es que una empresa que tiene una ________ .pdf
 
Load the German Credit data using the following code import.pdf
Load the German Credit data using the following code import.pdfLoad the German Credit data using the following code import.pdf
Load the German Credit data using the following code import.pdf
 
LO49 Explain how expression of related genes can be coordina.pdf
LO49 Explain how expression of related genes can be coordina.pdfLO49 Explain how expression of related genes can be coordina.pdf
LO49 Explain how expression of related genes can be coordina.pdf
 

Recently uploaded

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 

Recently uploaded (20)

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 

Linked List Objective The purpose of this exercise is to cr.pdf

  • 1. Linked List Objective: The purpose of this exercise is to create a Linked List data structure that mimics the behavior of the Java Standard Library Version (Java API). The outcomes/results of using the library features should be identical with your own version (My API). However, the underlying implementation should follow with the descriptions listed below. Instructions : Create the following Linked List Data Structure with the given description below in your utils package and use "for loops" for your repetitive tasks. Where to find starter code in my-api package.class : utils.LinkedList package.class : tests.console.week04.LinkedListTest Where to find your JUNIT test in my-api package.class : tests.junit.LinkedListJUnitTest Nested Class that has to be added to LinkedList class package.class : utils.LinkedList.Node Task Check List ONLY "for" loops should be used within the data structure class. There is an automatic 30% deduction, if other loops are used. The names of identifiers MUST match the names listed in the description below. Deductions otherwise. Complete coding Assignment in your "my-api" GitHub Repository. You will not be graded otherwise and will receive a 0, if not uploaded there. Run JUNIT TEST and take a SNAPSHOT of results. Upload PDF of snapshot of your JUnitTest results to Canvas. Description The internal structure of the Linked List is a doubly linked Node data structure and should have at a minimum the following specifications: data fields: The data fields to declare are private and you will keep track of the size of the list with the variable size and the start of the list with the reference variable data. first is a reference variable for the first Node<E> in the list. last is a reference variable for the last Node<E> in the list. size keeps track of the number of nodes in the list of type int. This will allow you to know the current size of the list without having to traversing the list. constructors: The overloaded constructors will initialize the data fields size and data. A constructor that is a default constructor initializes the starting node location first and size to a zero equivalent, that is, constructs an empty list. methods: methods that manages the behavior of the linked nodes. Together, the methods below give the illusion of a index or countable location. Implement these methods within your generic Linked List class. Method Description Header public boolean add(E item)
  • 2. public void add(int index, E item) public void append( E item) private void checkIndex(int index) public boolean contains(E item) public void clear() private E detach(int index) public E get(int index) public int indexOf(E item) private void insertBefore(int index, E item) public boolean isEmpty() private Node<E> node(int index) public E remove(int index) public boolean remove(E item) public E set(int index, E item) public int size() public String toString() Node Data Structure The generic Linked List class includes a static Node class as a nested class, i.e. a static inner class within the Linked List class. inner class: class inside the body of another class. Note: This private class does not require access to instance members of the outer class, so it is declared static. This means that the node object wont be coupled to the outer class object, thus will be more optimal since it wont require heap/stack memory. data fields: data : hold the data stored in each node as is of type E. next : stores the location of the next node in the list. prev : stores the location of the previous node in the list. constructor: A constructor that receives parameters for data, and prev and calls the second constructor. public Node(Node<E> prev, E data) A constructor that receives parameters for data, next and prev. public Node(Node<E> prev, E data, Node<E> next) Method Description Header add(item) uses the append method and ensures that there is enough spaces to store each element in the list. Also updates the number of elements in the list by one. This method returns true, if the data was added successfully. public boolean add(E item)
  • 3. add(index, item) inserts elements at a given location in the list, shifting subsequent elements to the right. Uses the append and insertBefore methods to assist with adding items to the front, back and middle of the list. Updates the number of elements in the list by one. public void add(int index, E item) append(item) appends elements to the end of the list, but does not update the number of elements. This is a private helper method. public void append( E item) checkIndex(index) checks if the given index is valid. Validation means that you cannot access indexes where elements have not been placed. Throws an IndexOutOfBoundsException , if invalid. This is a private helper method. private void checkIndex(int index) contains(item) searches for a specific item within the linked structure and returns true, if the item is in the list. public boolean contains(E item) clear() clears list of all elements, returns size back to zero. public void clear() detach(index) detaches the node at the specified index from list and returns the deleted element, but does not reduce the size of the list. This is a private helper method. private E detach(int index) get(index) returns the item at the specified position in the list. This method first checks if the index requested is valid. public E get(int index)
  • 4. indexOf(item) searches for a specific item within the linked structure and returns the first occurrence (i.e. index location) in the list, otherwise returns -1, if NOT found. public int indexOf(E item) insertBefore(index, item) inserts an item before the non- null node at the specified index in the list. Traverses the list to find this node. This method also checks for insertions at the start and end of the list, as well as when empty. This is a private helper method. private void insertBefore(int index, E item) isEmpty() returns true, if the list is empty, i.e., the list contains no elements. public boolean isEmpty() node(index) returns a reference to the node at the given position in the list. This node traverses the list in two directions from front to middle and back to middle. This is a private helper method. private Node<E> node(int index) remove(index) removes the item at the given position in the list for a valid index. Checks for valid index before it proceeds with removal. Shifts subsequent elements to the left and returns the item removed. The number of elements in the list is reduced by one. public E remove(int index) remove(item) removes the first occurrence of the specified item from the list, if present. Shifts subsequent elements to the left and returns true, if the item is removed. The number of elements in the list is reduced by one. public boolean remove(E item)
  • 5. set(index, item) replaces the item at the specified position with the one passed. This method checks if the index requested is valid before it does the replacement and returns the replaced item. public E set(int index, E item) size() returns the number of elements in the list. public int size() toString() displays the contents of the list according to the same format at shown in the Java API. public String toString()