Facebook

linked lists

Searching in Linked List

In searching,we find whether the given element is present in the linked list or not.The following program is to search for particular element in linked list. Program #include<stdio.h> struct node { int item; struct node *next }; int main() { struct node *start,*list,*temp; int i; int num; start = (struct node *)malloc(sizeof(struct node)); list =… read more »

Count number of nodes in Linked List

Counting refers to calculating number of nodes present in linked list. Program #include<stdio.h> struct node { int item; struct node *next }; int main() { struct node *start,*list,*temp; int i; start = (struct node *)malloc(sizeof(struct node)); list = start; start->next = NULL; for(i=1;i<5;i++) { list->item = i; list->next = (struct node *)malloc(sizeof(struct node)); list =… read more »

Deletion in Linked List

The elements of linked list can be deleted in three ways. Deletion at beginning Deletion at end Deletion at any location Program 1 #include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }*head,*var,*trav; int del_beg() { struct node *temp,*start; temp = start; start = start->next; free(temp); printf(“nThe Element deleted Successfully “); } int delete_from_middle(int… read more »

Insertion in Linked List

There are three ways to insert element in the linked list. Insertion in the beginning Insertion at the end At any location of user choice The following program deals with insertion in linked list. Program 1 #include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; } *head,*var,*trav; void insert_at_begning(int value) { var=(struct node *)malloc(sizeof… read more »

Linked Lists

Linked List is the data structure that stores data elements  in a sequence. Each data element is called a Node.Each node further contains data field/fields and a pointer(Refer :Pointers ) to next node(Fig 1). The  left part  of node has a data item and the right part of node has the address of succeeding node.The  address of elements may be  sequential or may be not. START  node has the address… read more »

Sidebar