You are on page 1of 3

C Programming Examples on Linked List

This section covers C programming examples on Linked Lists. Every example progra
m includes the description of the program, C code as well as output of the progr
am. All examples are compiled and tested on a Linux system. These examples can b
e simple C programs or advanced C programs. So, they are suitable for any user (
dummies, beginners or advanced users).
Here is the listing of C programming examples on Linked Lists.
1. C Examples on Creating and Displaying the elements of a Linked List
A Linked List is a dynamic data structure which contains memory blocks occupying
random memory locations. The elements in the linked list are called nodes. The
C programs in the following section focuses on the creation of a linked list and
displays the elements(nodes) of a Linked List. The other program in the section
s reads the linked list in reverse.
C Program to Create a Linked List & Display the Elements in the List
C Program to Read a Linked List in Reverse
2. C Examples on Search and Display Functions of a Linked List
The following section deals with the search and display functions which are appl
ied to the linked list. The Search function searches for the specified element i
n the linked list and the Display function is used to display the elements of th
e linked list. The section contains programs which use the Search function to se
arch for an element in the linked list using recursion and without using recursi
on. The remaining programs use the Display function to display the nodes of a li
nked list using recursion and without using recursion and to display the nodes o
f a linked list in reverse using recursion and without using recursion.
C Program to Search for an Element in the Linked List using Recursion
C Program to Search for an Element in the Linked List without using Recursion
C Program to Display the Nodes of a Linked List in Reverse using Recursion
C Program to Display all the Nodes in a Linked List using Recursion
C Program to Display all the Nodes in a Linked List without using Recursion
C Program to Display the Nodes of a Linked List in Reverse without using Recursi
on
3. C Examples on Implementation of Count, Length and Print Operations on a Linke
d List
The following section contains C Programs which performs operations like count,f
inding the length, and printing the elements of the linked list. The programs co
unt the number of occurrences of an element in the linked list using recursion a
nd without using recursion, determines the length of the linked list using recur
sion and without using recursion and displays the alternate nodes in a linked li
st using recursion and without using recursion.
C Program Count the Number of Occurrences of an Element in the Linked List using
Recursion
C Program Count the Number of Occurrences of an Element in the Linked List witho
ut using Recursion
C Program find the Length of the Linked List using Recursion
C Program find the Length of the Linked List without using Recursion
C Program to Print the Alternate Nodes in a Linked List using Recursion
C Program to Print the Alternate Nodes in a Linked List without using Recursion
4. C Examples on Implementation of other Data Structures using Linked List
The following section provides various implementations of other data structures
using linked list. It has programs to implement a Stack, to implement a Queue, t
o implement a Doubly Linked List, a Circular Doubly Linked List and a Binary Tre

e using linked list. Each node in a Doubly Linked List contains two address fiel
ds, one field stores the address of the previous node with which it is linked an
d the other address field stores the address of the next node to be followed. A
Circular Doubly Linked List is a doubly-linked-list in which the head element s pr
evious pointer points to the tail element and tail element s next pointer points t
o the head element. A Binary Tree is a group of nodes where each node contains a
left reference, a right reference and a data element. The section also contains
a C program which demonstrates the operations of a Singly Linked List. In a Sin
gly Linked List, each node has a single link to the other node.
C Program to Implement a Stack using Linked List
C Program to Implement Queue Data Structure using Linked List
C Program to Implement a Doubly Linked List & provide Insertion, Deletion & Disp
lay Operations
C Program to Implement Binary Tree using Linked List
C Program to Implement Circular Doubly Linked List
C Program to Illustrate the Operations of Singly Linked List
C Program to Implement Singly Linked List using Dynamic Memory Allocation
C Program to Implement Doubly Linked List using Singly Linked List
C Program to Demonstrate Circular Single Linked List
5. C Examples dealing with the Operations on the elements of a Linked List
This section contains C Programs which performs operations on the elements of a
linked list. These operations include addition of the corresponding elements of
2 linked lists, testing if the two linked lists are same, testing if the given S
ingly Linked List is a palindrome, finding the number of occurrences of all the
elements in a linked list. The section also involves finding the element that is
common to both the linked lists and finding the largest element in a Doubly Lin
ked List.
C Program to Add Corresponding Positioned Elements of 2 Linked Lists
C Program to Check whether 2 Lists are Same
C Program to Check whether a Singly Linked List is a Palindrome
C Program to Detect the Cycle in a Linked List
C Program to Find Number of Occurences of All Elements in a Linked List
C Program to Find the first Common Element between the 2 given Linked Lists
C Program to Find the Largest Element in a Doubly Linked List
6. C Examples on Print, Reverse and Read Operations
This sections has C programs which perform Print, Reverse and Read operations. P
rint operation prints the specified contents of a linked list, Read operation re
ads the content of the linked list, Remove operation removes the specific conten
ts of a linked list and Reverse operation reverses the contents of the given lin
ked list. The programs in this section prints the middle most node of a linked l
ist, reads a linked list in reverse, removes the duplicate elements from the lin
ked list, reverses a given linked list and reverses the first N elements of a gi
ven linked list.
C Program to Print Middle most Node of a Linked List
C Program to Read a Linked List in Reverse
C Program to Remove Duplicates from a Linked List
C Program to Reverse a Linked List
C Program to Reverse only First N Elements of a Linked List
7. C Examples on Binary Tree Implementation using Linked List
This section deals with implementation of other data structures like Ordered Bin
ary Tree, Balanced Binary Search Tree using a linked list. It also has programs
which convert one form of linked list to another. A balanced binary tree is a tr
ee where every leaf is not more than a certain distance away from the root than an
y other leaf. The following programs convert a Ordered Binary Tree Into a Circul

ar Doubly Linked List, Constructs a Balanced Binary Search Tree which have the s
ame data members as the given Doubly Linked List, Converts a Binary Tree into a
Singly Linked List and converts a Singly Linked List into a Circular List.
C Program that takes an Ordered Binary tree & Rearranges the Internal Pointers t
o make a Circular Doubly Linked List out of the Tree Nodes
C Program to Construct a Balanced Binary Search Tree which has same data members
as the given Doubly Linked List
C Program to Convert a Binary Tree into a Singly Linked List by Traversing Level
by Level
C Program to Convert a given Singly Linked List to a Circular List
C Program to Find Intersection & Union of 2 Linked Lists
8. C Examples on Interchange and Modify Operations
The programs in this section perform Interchange operations. They interchange th
e two adjacent nodes of a Circular Linked List by touching the key field and wit
hout touching the key field. The other program in the section performs the modif
y Operation. It modifies the given linked list such that all the even numbers ap
pear before the odd numbers in the given linked list. The section has some speci
al programs which solve mathematical problems like Josephus Problem using linked
list and a program which performs Infinite Precision Arithmetic.
C Program to Interchange the two Adjacent Nodes given a circular Linked List
C Program to Interchange two Elements of the List without touching the Key Field
C Program to Modify the Linked List such that All Even Numbers appear before all
the Odd Numbers in the Modified Linked List
C Program to Print Nth Node from the last of a Linked List
C Program to Solve Josephus Problem using Linked List

You might also like