SlideShare a Scribd company logo
1 of 5
Download to read offline
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 Objective The purpose of this exercise is to create a Linke.pdf

List Data Structure
List Data StructureList Data Structure
List Data StructureZidny Nafan
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructuresNguync91368
 
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.pdfxlynettalampleyxc
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)swajahatr
 
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
 
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.pdfaamousnowov
 
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.pdfalivaisi1
 
Seo Expert course in Pakistan
Seo Expert course in PakistanSeo Expert course in Pakistan
Seo Expert course in Pakistanssuserb2c86f
 
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
 
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 malavRohit malav
 
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
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfConint29
 
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.pdfinfo571050
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionssuseredfbe9
 

Similar to Objective The purpose of this exercise is to create a Linke.pdf (20)

List Data Structure
List Data StructureList Data Structure
List Data Structure
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
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
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
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
 
Advanced core java
Advanced core javaAdvanced core java
Advanced core java
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 
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
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
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
 
Java.util
Java.utilJava.util
Java.util
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
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
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 

More from giriraj65

Which of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfWhich of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfgiriraj65
 
Wheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfWheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfgiriraj65
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfgiriraj65
 
The resto txt Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt     Use for TM254 2021J TMA02 Question 6 .pdfThe resto txt     Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt Use for TM254 2021J TMA02 Question 6 .pdfgiriraj65
 
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfTableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfgiriraj65
 
Rios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfRios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfgiriraj65
 
Question 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfQuestion 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfgiriraj65
 
Problem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfProblem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfgiriraj65
 
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdfPLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdfgiriraj65
 
Please discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfPlease discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfgiriraj65
 
Mill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfMill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfgiriraj65
 
For each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfFor each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfgiriraj65
 
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1  Geor.pdfExercise I Georgettes and Georges Genotypes Gene 1  Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdfgiriraj65
 
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfEl 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfgiriraj65
 
Ests realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfEsts realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfgiriraj65
 
Assume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfAssume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfgiriraj65
 
a How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfa How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfgiriraj65
 
A Bucle remolino y arco B Crestas surcos y colinas .pdf
A  Bucle remolino y arco   B  Crestas surcos y colinas  .pdfA  Bucle remolino y arco   B  Crestas surcos y colinas  .pdf
A Bucle remolino y arco B Crestas surcos y colinas .pdfgiriraj65
 
68 Exercise Ferris Corporation makes a single product a f.pdf
68 Exercise Ferris Corporation makes a single product  a f.pdf68 Exercise Ferris Corporation makes a single product  a f.pdf
68 Exercise Ferris Corporation makes a single product a f.pdfgiriraj65
 
A special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfA special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfgiriraj65
 

More from giriraj65 (20)

Which of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdfWhich of these refers to the degree and nature of interdepen.pdf
Which of these refers to the degree and nature of interdepen.pdf
 
Wheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdfWheat crops across the Americas Asia Europe and Africa ar.pdf
Wheat crops across the Americas Asia Europe and Africa ar.pdf
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
The resto txt Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt     Use for TM254 2021J TMA02 Question 6 .pdfThe resto txt     Use for TM254 2021J TMA02 Question 6 .pdf
The resto txt Use for TM254 2021J TMA02 Question 6 .pdf
 
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdfTableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
Tableau DA 33 MiniCase Analyzing adjusting entries and p.pdf
 
Rios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdfRios Co is a regional insurance company that began operatio.pdf
Rios Co is a regional insurance company that began operatio.pdf
 
Question 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdfQuestion 1 2 pts Which of the following can be absolute defe.pdf
Question 1 2 pts Which of the following can be absolute defe.pdf
 
Problem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdfProblem 6 Create the Kmaps and then simplify for the followi.pdf
Problem 6 Create the Kmaps and then simplify for the followi.pdf
 
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdfPLEASE ANSWER PART A B C D  Thank you Kingbird Inc uses.pdf
PLEASE ANSWER PART A B C D Thank you Kingbird Inc uses.pdf
 
Please discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdfPlease discuss the following i Using examples for each typ.pdf
Please discuss the following i Using examples for each typ.pdf
 
Mill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdfMill Company began operations on January 1201 and recogni.pdf
Mill Company began operations on January 1201 and recogni.pdf
 
For each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdfFor each situation described below indicate which financial.pdf
For each situation described below indicate which financial.pdf
 
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1  Geor.pdfExercise I Georgettes and Georges Genotypes Gene 1  Geor.pdf
Exercise I Georgettes and Georges Genotypes Gene 1 Geor.pdf
 
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdfEl 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
El 23 de enero se adquieren 17000 acciones de Tolle Company.pdf
 
Ests realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdfEsts realizando experimentos de mejoramiento en maz Comie.pdf
Ests realizando experimentos de mejoramiento en maz Comie.pdf
 
Assume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdfAssume that a cross is made between AaBb and aabb plants and.pdf
Assume that a cross is made between AaBb and aabb plants and.pdf
 
a How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdfa How much money was eriginally invested t Show that th.pdf
a How much money was eriginally invested t Show that th.pdf
 
A Bucle remolino y arco B Crestas surcos y colinas .pdf
A  Bucle remolino y arco   B  Crestas surcos y colinas  .pdfA  Bucle remolino y arco   B  Crestas surcos y colinas  .pdf
A Bucle remolino y arco B Crestas surcos y colinas .pdf
 
68 Exercise Ferris Corporation makes a single product a f.pdf
68 Exercise Ferris Corporation makes a single product  a f.pdf68 Exercise Ferris Corporation makes a single product  a f.pdf
68 Exercise Ferris Corporation makes a single product a f.pdf
 
A special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdfA special interest speaks for a position or program which 1.pdf
A special interest speaks for a position or program which 1.pdf
 

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
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
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
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...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
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
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
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"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

Objective The purpose of this exercise is to create a Linke.pdf

  • 1. 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)
  • 2. 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()