Linked list

1.Traverse

struct node* h = head;
while (h != null)
{
    h = h->next;
}

2.Get the length of a linked list

int getLength(struct node* head)
{
    int length = 0;
    while (head != null)
    {
        length++;
        head = head->next;
    }
    return length;
}

3.Get the Nth element in a linked list

4.Pop the first element in the linked list

5.Delete all the elements in the linked list

6.Insert an element at the Nth

7.Insert an element at the right position in a sorted list

8.Append one list to the end of another

9.Append a new element to the end of a linked list

10.Front back split

11.Remove duplicates in a sorted list

12. Sorted merge

13.Move node from the head of one list and add to the front of another

14.Reverse

Last updated