Singly Linked List Insertion
Examine the C# implementation for the insertion of a node in a linked list.
We'll cover the following...
This lesson will briefly explain the basic operations, which were discussed in the previous lesson. The three types of insertion strategies used in singly LinkedList are:
- Insert at Head
- Insert at Tail
- Insert at the N-th index
Insertion at head
This type of insertion means that you will want to insert a new element as the first element of the list. As a result, the head pointer will point to the newly added node whose nextElement
, in turn, will point to the node previously pointed by the head or null
value.
Insert at tail
This type of insertion means that you will want to insert a new element as the last element of the list. The original tail
element of the list has a nextElement
pointer that points to NULL
. To insert a new tail
node, you have to point the nextElement
pointer of the previous tail
node to the new tail
node, and the nextElement
of the new ...