Posts

Showing posts from March, 2026

Linked list implementation in C

               It is a mostly used linear data structure in programming. Linked list has a collection of nodes and pointers. Pointers has the address of the next node. Node has the data. First node is called Head node. Last node has null pointer. Let us implement the linked list with insertion operation. Program: #include <stdio.h> #include <stdlib.h> // creation of   the node structure struct l_Node {     int n_data;     struct l_Node* next; }; //create a new node struct l_Node* createNode(int n_data) {     struct l_Node* newNode = (struct l_Node*)malloc(sizeof(struct l_Node));     if (!newNode) {         printf("Memory is not allocated\n");         exit(1);     }     newNode->n_data = n_data;     newNode->next = NUL...