Data structure
Data Structure
A Data Structure is a particular way of organizing data in a computer so
that it can be used effectively.
For Example : we can store a list of items having the same data-type using
the array data structure.
U B F D A E C . . .
Dynamic Allocation Memory
Function Code Task
Malloc() ptr = (cast-type*) malloc(byte-size) Allocates request size
of bytes and returns a
pointer to the first
bytes of the allocated
Space.
Calloc() ptr = (cast-type*)calloc(n, element-size); Allocates space for an
array of elements,
initializes them to
zero and then returns
a pointer to the
memory.
Function Code Task
Free() free(ptr); Frees previously
allocated space.
Realloc() ptr = realloc(ptr, newSize); Modifies the size of
previously allocated
space.
• A linked list is a series of connected nodes
• Each node contains at least
– A piece of data (any type)
– Pointer to the next node in the list
• Head: pointer to the first node
• The last node points to NULL
Single Linked List
• Singly linked list is a
collection of
nodes linked together
in a sequential way
where each node
of singly linked
list contains a data
field and an address
field which contains
the reference of the
next node.
Circular Linked List
• The last node points
to the first node of the
list
• How do we know
when we have
finished traversing the
list? (Tip: check if the
pointer of the current
node is equal to the
head.)
Doubly linked lists
• Each node points to
not only successor but
the predecessor
• There are two NULL:
at the first and last
nodes in the list
• Advantage: given a
node, it is easy to
visit its predecessor.
Convenient to
traverse lists
backwards
Single Linked List
• A linked list we must keep track/reference of the first
node which may be referred by head pointer
variable. In singly linked list address field of last node
must contain a NULL value specifying end of the list.
struct node
{
int data; //Data
node * next; // Address
};
Circular Linked List
I. A circular linked list is basically a linear linked list that may be singly or doubly. The only difference is
that there is no any NULL value terminating the list. In fact in the list every node points to the next node
and last node points to the first node, thus forming a circle. Since it forms a circle with no end to stop
hence it is called as circular linked list.
• Algorithm to create circular linked list
• %%Input : N {Total number of nodes to be created}
• Being: alloc (head)
• read (data)
• head.data ← data;
• head.next ← NULL;
• prevNode ← head;
• For count ← 2 to N do alloc (newNode)
• read (data) newNode.data ← data;
• newNode.next ← NULL;
• prevNode.next ← newNode;
• prevNode ← newNode;
• End for
• prevNode.next ← head;
• End
Doubly linked list
Doubly linked list is a collection of nodes linked together in a sequential way. Each node of the list
contains two parts (as in singly linked list) data part and the reference or address part. The
basic structure of node is shown in the below image:
struct node { int data; // Data field
struct node * prev; // Address of previous node
struct node * next; // Address of next node };

More Related Content

PPTX
Linked list
PPTX
Singly Linked List
PPTX
Dynamic memory allocation and linked lists
PDF
Linked list (introduction) 1
PPT
Introduction to data structure by anil dutt
PPTX
Data structure & its types
PPTX
Linked Lists
PPT
Extensible hashing
Linked list
Singly Linked List
Dynamic memory allocation and linked lists
Linked list (introduction) 1
Introduction to data structure by anil dutt
Data structure & its types
Linked Lists
Extensible hashing

What's hot (20)

PPT
Starting work with R
PPTX
General Data structures
PPTX
DATA STRUCTURE IN C LANGUAGE
PPTX
Application of Data structure
PPTX
Presentation on Data Structure
PPTX
Introduction to data structure ppt
PDF
Data Structure Basics
PDF
Introduction to data structure
PPTX
Data Structures
PPT
Data structure lecture 1
PPT
Introduction to data structure
PPT
Introductiont To Aray,Tree,Stack, Queue
PPTX
DATA STRUCTURE
PPTX
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
PDF
PPTX
Introduction to Data Structure part 1
PPTX
Types Of Data Structure
PPTX
Data Structures
Starting work with R
General Data structures
DATA STRUCTURE IN C LANGUAGE
Application of Data structure
Presentation on Data Structure
Introduction to data structure ppt
Data Structure Basics
Introduction to data structure
Data Structures
Data structure lecture 1
Introduction to data structure
Introductiont To Aray,Tree,Stack, Queue
DATA STRUCTURE
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Introduction to Data Structure part 1
Types Of Data Structure
Data Structures
Ad

Similar to Data structure (20)

PPTX
DATA STRUCTURES AND LINKED LISTS IN C.pptx
PPTX
DATA STRUCTURES AND LINKED LISTS IN C.pptx
PPTX
Linked list using Dynamic Memory Allocation
PPTX
Data Structures Introduction & Linear DS
PPTX
Linked List in Data Structure
PPTX
Data structures2
PPTX
Linked List Data structure using C programming and all the detailed informat...
PDF
DS Module 03.pdf
PPTX
linked_list.pptx
PDF
14_linked list_updated-updated-updated(1).pdf
PPTX
Linked Lists, Single Linked list and its operations
PPTX
Unit 1 LINEAR DATA STRUCTURES
PPTX
Ll.pptx
PPTX
linked list.pptx
PPT
DS Unit 2.ppt
PPTX
UNIT 3a.pptx
PPTX
unit 1.pptx
PDF
Linked list
PPTX
Deleting a node from the list(SINGLE LINKED LIST)
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
Linked list using Dynamic Memory Allocation
Data Structures Introduction & Linear DS
Linked List in Data Structure
Data structures2
Linked List Data structure using C programming and all the detailed informat...
DS Module 03.pdf
linked_list.pptx
14_linked list_updated-updated-updated(1).pdf
Linked Lists, Single Linked list and its operations
Unit 1 LINEAR DATA STRUCTURES
Ll.pptx
linked list.pptx
DS Unit 2.ppt
UNIT 3a.pptx
unit 1.pptx
Linked list
Deleting a node from the list(SINGLE LINKED LIST)
Ad

Recently uploaded (20)

PDF
Best Data Science Professional Certificates in the USA | IABAC
PDF
A biomechanical Functional analysis of the masitary muscles in man
PDF
Microsoft Core Cloud Services powerpoint
PPTX
ai agent creaction with langgraph_presentation_
PPT
DU, AIS, Big Data and Data Analytics.ppt
PPTX
Machine Learning and working of machine Learning
PPTX
statsppt this is statistics ppt for giving knowledge about this topic
PPT
Image processing and pattern recognition 2.ppt
PDF
Navigating the Thai Supplements Landscape.pdf
PPT
statistics analysis - topic 3 - describing data visually
PPTX
CYBER SECURITY the Next Warefare Tactics
PPT
PROJECT CYCLE MANAGEMENT FRAMEWORK (PCM).ppt
PPTX
New ISO 27001_2022 standard and the changes
PPTX
FMIS 108 and AISlaudon_mis17_ppt_ch11.pptx
PPTX
SET 1 Compulsory MNH machine learning intro
PPTX
recommendation Project PPT with details attached
PDF
Session 11 - Data Visualization Storytelling (2).pdf
PDF
OneRead_20250728_1808.pdfhdhddhshahwhwwjjaaja
PDF
Systems Analysis and Design, 12th Edition by Scott Tilley Test Bank.pdf
PPTX
IMPACT OF LANDSLIDE.....................
Best Data Science Professional Certificates in the USA | IABAC
A biomechanical Functional analysis of the masitary muscles in man
Microsoft Core Cloud Services powerpoint
ai agent creaction with langgraph_presentation_
DU, AIS, Big Data and Data Analytics.ppt
Machine Learning and working of machine Learning
statsppt this is statistics ppt for giving knowledge about this topic
Image processing and pattern recognition 2.ppt
Navigating the Thai Supplements Landscape.pdf
statistics analysis - topic 3 - describing data visually
CYBER SECURITY the Next Warefare Tactics
PROJECT CYCLE MANAGEMENT FRAMEWORK (PCM).ppt
New ISO 27001_2022 standard and the changes
FMIS 108 and AISlaudon_mis17_ppt_ch11.pptx
SET 1 Compulsory MNH machine learning intro
recommendation Project PPT with details attached
Session 11 - Data Visualization Storytelling (2).pdf
OneRead_20250728_1808.pdfhdhddhshahwhwwjjaaja
Systems Analysis and Design, 12th Edition by Scott Tilley Test Bank.pdf
IMPACT OF LANDSLIDE.....................

Data structure

  • 2. Data Structure A Data Structure is a particular way of organizing data in a computer so that it can be used effectively. For Example : we can store a list of items having the same data-type using the array data structure. U B F D A E C . . .
  • 3. Dynamic Allocation Memory Function Code Task Malloc() ptr = (cast-type*) malloc(byte-size) Allocates request size of bytes and returns a pointer to the first bytes of the allocated Space. Calloc() ptr = (cast-type*)calloc(n, element-size); Allocates space for an array of elements, initializes them to zero and then returns a pointer to the memory.
  • 4. Function Code Task Free() free(ptr); Frees previously allocated space. Realloc() ptr = realloc(ptr, newSize); Modifies the size of previously allocated space.
  • 5. • A linked list is a series of connected nodes • Each node contains at least – A piece of data (any type) – Pointer to the next node in the list • Head: pointer to the first node • The last node points to NULL
  • 6. Single Linked List • Singly linked list is a collection of nodes linked together in a sequential way where each node of singly linked list contains a data field and an address field which contains the reference of the next node. Circular Linked List • The last node points to the first node of the list • How do we know when we have finished traversing the list? (Tip: check if the pointer of the current node is equal to the head.) Doubly linked lists • Each node points to not only successor but the predecessor • There are two NULL: at the first and last nodes in the list • Advantage: given a node, it is easy to visit its predecessor. Convenient to traverse lists backwards
  • 7. Single Linked List • A linked list we must keep track/reference of the first node which may be referred by head pointer variable. In singly linked list address field of last node must contain a NULL value specifying end of the list. struct node { int data; //Data node * next; // Address };
  • 8. Circular Linked List I. A circular linked list is basically a linear linked list that may be singly or doubly. The only difference is that there is no any NULL value terminating the list. In fact in the list every node points to the next node and last node points to the first node, thus forming a circle. Since it forms a circle with no end to stop hence it is called as circular linked list. • Algorithm to create circular linked list • %%Input : N {Total number of nodes to be created} • Being: alloc (head) • read (data) • head.data ← data; • head.next ← NULL; • prevNode ← head; • For count ← 2 to N do alloc (newNode) • read (data) newNode.data ← data; • newNode.next ← NULL; • prevNode.next ← newNode; • prevNode ← newNode; • End for • prevNode.next ← head; • End
  • 9. Doubly linked list Doubly linked list is a collection of nodes linked together in a sequential way. Each node of the list contains two parts (as in singly linked list) data part and the reference or address part. The basic structure of node is shown in the below image: struct node { int data; // Data field struct node * prev; // Address of previous node struct node * next; // Address of next node };