C Program to Delete the First Node of a Linked List

Here we’ll see how write C program to delete the first node of a linked list. Head always points to the first node. Head will move to where the first node is currently pointing to. First node can either point to the second node or to NULL in case the first node is the only … Continue reading “C Program to Delete the First Node of a Linked List”

C Program to Reverse a Linked List

Reversing a linked list means re-arranging the next (connection) pointers. Head will point to the last node and the first node will point to NULL. Direction of other next pointers will change. If a linked list looks like this: After reversal, it will look like: Logic to Reverse a Linked List Take the first node … Continue reading “C Program to Reverse a Linked List”

C Program to Search for an Element in Linked List

Here we’ll see how to write a C program to find an element in a linked list. The function is_present() takes a linked list (head pointer) and a value (val) as input arguments. If the value (val) is present in any of the nodes, this function returns the pointer of that node. Otherwise it returns … Continue reading “C Program to Search for an Element in Linked List”

C Program to Print the Length of a Linked List

Here we’ll see how to write a C program to print the length of a linked list. The function get_length() takes a linked list as input and returns the length of it. First we’ll create a linked list and pass that list to the get_length() function to print the length of the list. The get_length() … Continue reading “C Program to Print the Length of a Linked List”

C Program to Check Whether Two Linked Lists are Equal

Here we’ll see how to write a C program to compare two linked lists. First we’ll create three linked lists, first two are equal and third one is different. We’ll compare these linked lists using the check_equal() function. The check_equal() function traverses the linked lists until at least one of them reaches to NULL (end). … Continue reading “C Program to Check Whether Two Linked Lists are Equal”

2
2
1
3
10
1