Singly LinkList consist of a number of nodes in which each nodes has a next pointer to the following element . The List of the last node in the list is NULL which indicates the end of the List.
Basic operations on a List
Traversing the list.
Inserting an item in to the list.
Deleting a item from the list.
For creating declaration for a link nodes to create linklist.
Traversing is basically displaying the known nodes.
We also do the same operation for two purposes one is to display the nodes and other is to take size of the entire List.
follow the pointers .
Display the contents of the node or count as they are traversed .
Stop the next pointer points to Null .
creating a method for display list
creating a method for counting the length of the list.
Singly List insertion
Inserting a node at the beginning of the list.
Update the next pointer of new node,to point he current node.
Update the head pointer to point he new node .
Inserting a node at End
New nodes next pointer points to the null .
last nodes pointer pointer points to the new node .
Inserting a node at middle by position.
If we want to insert a element in nth position then we stop at (n-1)th position . The pointer of the n-1 position node points to the nth node ,This node is called position node.
n-1th node points to the new node .
new node points the remaining node .
Singly List Deletion
Deleting first node in Singly Link List.
set first node to fist to first next pointer .
Deleting last node in Singly link list .
Traverse through the list till reach at previous pointer point to last node .
make the previous node to last and next pointer of previous to null
Deleting intermediate nodes in singly list.
This can be in two methods , one is to find the position and delete the element in the position and second is to delete the node directly .
Traverse through the node till reach the previous position of the element to delete .
one we found the node to be deleted, change the previous nodes next pointer of the node to be deleted.
For deleting element
For deleting element by position
For full and Executable program SingleLinkListAPP