We will be discussing the various operations of Linked List we mentioned in our previous post.
The basic operations performed in a Linked List are
The basic operations performed in a Linked List are
- Addition of a node.
- Deleting a node.
- Searching for a node.
- Display the Linked List.
Addition of a node to the list.
Here we will be adding a node to the beginning of the list and make the head point to the newly added node. Below is a code to add at the beginning of the list.
private void addNode(LinkedNode node) {
if(head == null){
head = node;
return;
}
else{
LinkedNode temp = head;
while(temp.next != null){
temp = temp.next;
}
temp.next = node;
}
}
We will discuss the other operations in coming tutorials.Hope you like it. Please comment on doubts.
Happy Learning !!!
0 comments :
Post a Comment