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 advancethchnologies

On day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
On day 1 of the menstrual cycle FSH levels will be 25 pts .pdfOn day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
On day 1 of the menstrual cycle FSH levels will be 25 pts .pdfadvancethchnologies
 
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdfOn August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdfadvancethchnologies
 
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdfOn April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdfadvancethchnologies
 
On any given day the probability that Marco eats sushi for .pdf
On any given day the probability that Marco eats sushi for .pdfOn any given day the probability that Marco eats sushi for .pdf
On any given day the probability that Marco eats sushi for .pdfadvancethchnologies
 
Objective Draw the data path and interface with the control.pdf
Objective Draw the data path and interface with the control.pdfObjective Draw the data path and interface with the control.pdf
Objective Draw the data path and interface with the control.pdfadvancethchnologies
 
On a certain island there is a population of snakes foxes.pdf
On a certain island there is a population of snakes foxes.pdfOn a certain island there is a population of snakes foxes.pdf
On a certain island there is a population of snakes foxes.pdfadvancethchnologies
 
Omnichannel retailing is A when a retailer either closes .pdf
Omnichannel retailing is A when a retailer either closes .pdfOmnichannel retailing is A when a retailer either closes .pdf
Omnichannel retailing is A when a retailer either closes .pdfadvancethchnologies
 
Omigo On a Mission to Create a Bidet Culture in the United .pdf
Omigo On a Mission to Create a Bidet Culture in the United .pdfOmigo On a Mission to Create a Bidet Culture in the United .pdf
Omigo On a Mission to Create a Bidet Culture in the United .pdfadvancethchnologies
 
Olfactory receptor cells and auditory receptors share the fo.pdf
Olfactory receptor cells and auditory receptors share the fo.pdfOlfactory receptor cells and auditory receptors share the fo.pdf
Olfactory receptor cells and auditory receptors share the fo.pdfadvancethchnologies
 
Olivia a oneyearold infant is brought to the emergency r.pdf
Olivia a oneyearold infant is brought to the emergency r.pdfOlivia a oneyearold infant is brought to the emergency r.pdf
Olivia a oneyearold infant is brought to the emergency r.pdfadvancethchnologies
 
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdfOkul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdfadvancethchnologies
 
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdfoklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdfadvancethchnologies
 
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdfOkuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdfadvancethchnologies
 
okay ment rebuild the project what is the first ertor you g.pdf
okay ment rebuild the project what is the first ertor you g.pdfokay ment rebuild the project what is the first ertor you g.pdf
okay ment rebuild the project what is the first ertor you g.pdfadvancethchnologies
 
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdfok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdfadvancethchnologies
 
Office Automation Inc developed a proposal for implementin.pdf
Office Automation Inc developed a proposal for implementin.pdfOffice Automation Inc developed a proposal for implementin.pdf
Office Automation Inc developed a proposal for implementin.pdfadvancethchnologies
 
Of the 214 million US firms without paid employees 32 a.pdf
Of the 214 million US firms without paid employees 32 a.pdfOf the 214 million US firms without paid employees 32 a.pdf
Of the 214 million US firms without paid employees 32 a.pdfadvancethchnologies
 
Of the following which is NOT true about the service econom.pdf
Of the following which is NOT true about the service econom.pdfOf the following which is NOT true about the service econom.pdf
Of the following which is NOT true about the service econom.pdfadvancethchnologies
 
Of the following which is the biggest risk factor for the d.pdf
Of the following which is the biggest risk factor for the d.pdfOf the following which is the biggest risk factor for the d.pdf
Of the following which is the biggest risk factor for the d.pdfadvancethchnologies
 
Of the four universal forces strong weak electromagnetic.pdf
Of the four universal forces strong weak electromagnetic.pdfOf the four universal forces strong weak electromagnetic.pdf
Of the four universal forces strong weak electromagnetic.pdfadvancethchnologies
 

More from advancethchnologies (20)

On day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
On day 1 of the menstrual cycle FSH levels will be 25 pts .pdfOn day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
On day 1 of the menstrual cycle FSH levels will be 25 pts .pdf
 
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdfOn August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
On August 2 1971 Commander Scott of Apollo 15 confirmed Ga.pdf
 
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdfOn April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
On April 1 2024 Ivanhoe Company purchased 41600 common sh.pdf
 
On any given day the probability that Marco eats sushi for .pdf
On any given day the probability that Marco eats sushi for .pdfOn any given day the probability that Marco eats sushi for .pdf
On any given day the probability that Marco eats sushi for .pdf
 
Objective Draw the data path and interface with the control.pdf
Objective Draw the data path and interface with the control.pdfObjective Draw the data path and interface with the control.pdf
Objective Draw the data path and interface with the control.pdf
 
On a certain island there is a population of snakes foxes.pdf
On a certain island there is a population of snakes foxes.pdfOn a certain island there is a population of snakes foxes.pdf
On a certain island there is a population of snakes foxes.pdf
 
Omnichannel retailing is A when a retailer either closes .pdf
Omnichannel retailing is A when a retailer either closes .pdfOmnichannel retailing is A when a retailer either closes .pdf
Omnichannel retailing is A when a retailer either closes .pdf
 
Omigo On a Mission to Create a Bidet Culture in the United .pdf
Omigo On a Mission to Create a Bidet Culture in the United .pdfOmigo On a Mission to Create a Bidet Culture in the United .pdf
Omigo On a Mission to Create a Bidet Culture in the United .pdf
 
Olfactory receptor cells and auditory receptors share the fo.pdf
Olfactory receptor cells and auditory receptors share the fo.pdfOlfactory receptor cells and auditory receptors share the fo.pdf
Olfactory receptor cells and auditory receptors share the fo.pdf
 
Olivia a oneyearold infant is brought to the emergency r.pdf
Olivia a oneyearold infant is brought to the emergency r.pdfOlivia a oneyearold infant is brought to the emergency r.pdf
Olivia a oneyearold infant is brought to the emergency r.pdf
 
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdfOkul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
Okul andaki nfusun yzde on drd zel okullara gidiyor ve.pdf
 
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdfoklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
oklu ve ldrc aleller neden klasik Mendel monohibrit ve .pdf
 
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdfOkuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
Okuyucunun trevleri anladn ve anlk hzn dxdt tanmn bildii.pdf
 
okay ment rebuild the project what is the first ertor you g.pdf
okay ment rebuild the project what is the first ertor you g.pdfokay ment rebuild the project what is the first ertor you g.pdf
okay ment rebuild the project what is the first ertor you g.pdf
 
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdfok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
ok hcre saln destekleyen oksijenin verilmesi ve gereksinim.pdf
 
Office Automation Inc developed a proposal for implementin.pdf
Office Automation Inc developed a proposal for implementin.pdfOffice Automation Inc developed a proposal for implementin.pdf
Office Automation Inc developed a proposal for implementin.pdf
 
Of the 214 million US firms without paid employees 32 a.pdf
Of the 214 million US firms without paid employees 32 a.pdfOf the 214 million US firms without paid employees 32 a.pdf
Of the 214 million US firms without paid employees 32 a.pdf
 
Of the following which is NOT true about the service econom.pdf
Of the following which is NOT true about the service econom.pdfOf the following which is NOT true about the service econom.pdf
Of the following which is NOT true about the service econom.pdf
 
Of the following which is the biggest risk factor for the d.pdf
Of the following which is the biggest risk factor for the d.pdfOf the following which is the biggest risk factor for the d.pdf
Of the following which is the biggest risk factor for the d.pdf
 
Of the four universal forces strong weak electromagnetic.pdf
Of the four universal forces strong weak electromagnetic.pdfOf the four universal forces strong weak electromagnetic.pdf
Of the four universal forces strong weak electromagnetic.pdf
 

Recently uploaded

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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
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
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
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
 
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
 
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
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Recently uploaded (20)

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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
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...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
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
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
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
 
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"
 
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
 
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...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

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()