SlideShare a Scribd company logo
1 of 4
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 in the list.
last is a reference variable for the last Node 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 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 prev, E data)
A constructor that receives parameters for data, next and prev.
public Node(Node prev, E data, Node 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 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 Linked List d.pdf

Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfalsofshionchennai
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfmaheshkumar12354
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)swajahatr
 
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
 
List Data Structure
List Data StructureList Data Structure
List Data StructureZidny Nafan
 
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
 
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
 
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
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionssuseredfbe9
 
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
 
Java Amend the LinkedList so that 1 Your list classes must.pdf
Java Amend the LinkedList so that 1 Your list classes must.pdfJava Amend the LinkedList so that 1 Your list classes must.pdf
Java Amend the LinkedList so that 1 Your list classes must.pdfadinathassociates
 
Lecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxLecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxSHIVA101531
 

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

Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdf
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdf
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
Array list(1)
Array list(1)Array list(1)
Array list(1)
 
Advanced core java
Advanced core javaAdvanced core java
Advanced core java
 
Unsorted Sorted List_Array.pptx
Unsorted Sorted List_Array.pptxUnsorted Sorted List_Array.pptx
Unsorted Sorted List_Array.pptx
 
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
 
List data structure
List data structure List data structure
List data structure
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 
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
 
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
 
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
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 
Linked list (java platform se 8 )
Linked list (java platform se 8 )Linked list (java platform se 8 )
Linked list (java platform se 8 )
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
Java Amend the LinkedList so that 1 Your list classes must.pdf
Java Amend the LinkedList so that 1 Your list classes must.pdfJava Amend the LinkedList so that 1 Your list classes must.pdf
Java Amend the LinkedList so that 1 Your list classes must.pdf
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 
Lecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxLecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docx
 

More from aliracreations

One unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdfOne unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdfaliracreations
 
One of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdfOne of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdfaliracreations
 
One of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdfOne of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdfaliracreations
 
One common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdfOne common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdfaliracreations
 
Once you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdfOnce you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdfaliracreations
 
Once you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdfOnce you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdfaliracreations
 
One day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdfOne day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdfaliracreations
 
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdfOn November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdfaliracreations
 
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdfOn January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdfaliracreations
 
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdfOn January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdfaliracreations
 
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdfOn December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdfaliracreations
 
No plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdfNo plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdfaliracreations
 
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdfOn August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdfaliracreations
 
On April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdfOn April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdfaliracreations
 
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdfOn 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdfaliracreations
 
New York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdfNew York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdfaliracreations
 
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdfnsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdfaliracreations
 
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdfnsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdfaliracreations
 
Nurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdfNurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdfaliracreations
 
Nowadays, due to the sophistication of adversarial attack vectors, t.pdf
Nowadays, due to the sophistication of adversarial attack vectors, t.pdfNowadays, due to the sophistication of adversarial attack vectors, t.pdf
Nowadays, due to the sophistication of adversarial attack vectors, t.pdfaliracreations
 

More from aliracreations (20)

One unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdfOne unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdf
 
One of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdfOne of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdf
 
One of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdfOne of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdf
 
One common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdfOne common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdf
 
Once you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdfOnce you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdf
 
Once you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdfOnce you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdf
 
One day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdfOne day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdf
 
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdfOn November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
 
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdfOn January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
 
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdfOn January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
 
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdfOn December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
 
No plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdfNo plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdf
 
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdfOn August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
 
On April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdfOn April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdf
 
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdfOn 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
 
New York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdfNew York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdf
 
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdfnsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
 
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdfnsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
 
Nurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdfNurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdf
 
Nowadays, due to the sophistication of adversarial attack vectors, t.pdf
Nowadays, due to the sophistication of adversarial attack vectors, t.pdfNowadays, due to the sophistication of adversarial attack vectors, t.pdf
Nowadays, due to the sophistication of adversarial attack vectors, t.pdf
 

Recently uploaded

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
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
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 

Recently uploaded (20)

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
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
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 

Objective The purpose of this exercise is to create a Linked List d.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 in the list. last is a reference variable for the last Node in the list. size keeps track of the number of nodes in the list of type int. This will allow you to know the
  • 2. 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 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.
  • 3. 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 prev, E data) A constructor that receives parameters for data, next and prev. public Node(Node prev, E data, Node 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.
  • 4. 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 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()