Professional Documents
Culture Documents
CPE6 Unit 4
CPE6 Unit 4
CPE6 Unit 4
Data
Structures and
Algorithms
LinkedList Operations
Week 4
Computer Engineering - CPE6
Week 4
Computer Engineering - CPE6
Week 4
Computer Engineering - CPE6
null
Week 4
Computer Engineering - CPE6
Singly Linked
List
null
Week 4
Computer Engineering - CPE6
Week 4
Computer Engineering - CPE6
node1 node2
null node3
null null
Method:
insert(“node3”)
insert(“node1”)
insert(“node2”)
Week 4
Computer Engineering - CPE6
4. Create an insert() method with public access modifier and void as return type. Accept a
parameter named value which is of type String.
Week 4
Computer Engineering - CPE6
6. Create a setNext() method with public access modifier and void as return type. Accept a
parameter named sllNext which is of type SinglyLL and v which is of type String.
8. Create a getValue() method with public access modifier and String as return type. Return
data.
Week 4
Computer Engineering - CPE6
List ADT
insert() – Insert an element at the current location.
clear() – Remove all elements in the list.
append() – Insert an element at the end of the list.
moveToStart() – Set the current location to the start of the list.
moveToEnd() – Set the current location to the end of the list.
length() – Returns the number of elements in the list.
currPos() – Returns the current position in the list.
moveToPos(int pos) – set the current position to “pos”.
getValue() – returns the value of the current position.
next() – Move to the next node.
prev() – Move to the previous node.
Week 3
Computer Engineering - CPE6
THANKS!
DO YOU HAVE ANY QUESTIONS?
Week 4