0% found this document useful (0 votes)
10 views10 pages

247R1A05M4DS Lab

The document provides an overview of linked lists as a linear data structure, detailing their node structure and types, including singly, doubly, and circular linked lists. It outlines the steps for displaying a singly linked list and discusses the advantages and disadvantages of using linked lists compared to other data structures. The content is prepared by J. Ganesh as part of a data structure course at CMR Technical Campus.

Uploaded by

247r1a66k7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

247R1A05M4DS Lab

The document provides an overview of linked lists as a linear data structure, detailing their node structure and types, including singly, doubly, and circular linked lists. It outlines the steps for displaying a singly linked list and discusses the advantages and disadvantages of using linked lists compared to other data structures. The content is prepared by J. Ganesh as part of a data structure course at CMR Technical Campus.

Uploaded by

247r1a66k7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

CMR TECHNICAL CAMPUS

UGC AUTONOMOUS
Accredited by NBA & NAAC With ‘A’ Grade
Approved by AICTE,NEW Delhi and JNTUH Hyderabad

PREPARED BY:-

J.GANESH
247R1A05M4
CSE_D
DATA STRUCTURE
Implementation of
Linked List
Creation, Insertion, and
Display
INTRODUCTION
:-
1. Data structure is a method of organizing a large amount of data
more efficiently so that any operation on that data becomes easy.

2. If a data structure organizes the data in sequential order, then


that data structure is called a Linear Data Structure.

3. The linked list is a linear data structure that contains a sequence


of elements such that each element links to its next element in the
sequence. Each element in a linked list is called “Node”
Node Structure
• struct Node {
• int data;
• struct Node* next;
• };
•Linked Lists:-

• A linked list is a linear data structure where
elements, called nodes, are stored in a sequence,
but unlike arrays, they are not stored in contiguous
memory locations. Instead, each node contains:

• 1. Data – the actual value stored.
2. Pointer (or Link) – a reference to the next node in
the sequence.
• Types of Linked Lists:-

1. Singly Linked List – Each node points to the next
node.

2. Doubly Linked List – Each node points to both the


next and previous nodes.

3. Circular Linked List – The last node points back to the


first node, forming a circle (can be singly or doubly
circular).
• Displaying a Single Linked List:-

• We can use the following steps to display the elements of a single linked list...
• Step 1 – Check whether list is Empty(head = NULL)
• Step 2- If it is Empty then, display ‘List is Empty!!!’ and terminate the function.
• Step 3 – If it is Not Empty then, define a Node pointer ‘temp’ and initialize with
head.
Step 4 – Keep displaying temp → data with an arrow (-) until temp reaches to the
last node.
Step 5 -Finally display temp→ data with arrow pointing to NULL(temp → data -
NULL).
ADVANTAGES AND DISADVANTAGES

✅Advantages 🚫 Disadvantages
✅ Dynamic size (no fixed limit) ❌ Extra memory for pointers

❌ Slow access (no random access like


✅ Easy insertions/deletions
arrays)

✅ No memory wastage (allocates as


❌ Searching takes more time (O(n))
needed)

✅ Great for implementing data ❌ Pointer handling is tricky and error-


structures prone

❌ Not cache friendly (non-contiguous


✅ Efficient at front/middle insertions
memory)
THANK YOU!

You might also like