Data Structure and its
operations
Paper Code- PCC CS 301
Paper name – Data structure &
Algorithm
Name –
Roll no.-
Stream – CSE
Year & semester-
Collage Code- 106
Introduction & Definition of Data
Structure
Definition:
A data structure is a method of organizing, storing, and
managing data so that it can be accessed and modified
efficiently.
Key Points:
• Determines how data is arranged in memory.
• Helps in efficient storage and retrieval.
• Supports different types of operations (insertion,
deletion, searching, sorting, etc.).
Examples:
• Linear: Arrays, Linked Lists
• Non-Linear: Trees, Graphs
Need for Data
Structure
Why We Need Data Structures:
• Efficient Data Access & Manipulation: Retrieve and
update data quickly.
• Better Memory Usage: Avoid wastage by storing data
efficiently.
• Simplifies Complex Problems: Makes implementation
of algorithms easier.
• Supports Data Abstraction: Focus on what
operations do, not how they work internally.
Example Scenario:
• Without Data Structure: Searching a name in an
unsorted list → takes longer.
• With Proper Data Structure (Binary Search
Tree): Search becomes faster as data is organized
hierarchically.
ABSTRACT DATA TYPE (ADT)
Definition:
An Abstract Data Type (ADT) is a logical model for data types
where the implementation details are hidden, and only the set
of operations that can be performed on the data is specified.
Key Points:
• Focuses on what operations are performed, not how they are
implemented.
• Provides a clear interface for the user.
• Improves modularity and reusability of code.
Examples:
• Stack: push, pop
• Queue: enqueue, dequeue
• List
• Map
CLASSIFICATION OF DATA STRUCTURES
Main Types:
[Link] Data Structures (Basic Data Types)
•Directly supported by most programming languages.
•Examples: int, float, char, Boolean.
[Link]-Primitive Data Structures (Structured / Derived Types)
•Built using primitive types, can store large and complex data.
•Examples: Arrays, Linked Lists, Stacks, Queues, Trees, Graphs .
LINEAR DATA STRUCTURE: A STRUCTURE WHERE DATA ELEMENTS ARE
ARRANGED SEQUENTIALLY, ONE AFTER ANOTHER.
NON-LINEAR DATA STRUCTURE: A STRUCTURE WHERE DATA ELEMENTS ARE
CONNECTED IN A HIERARCHICAL OR NETWORK MANNER.
Primitive vs Non-Primitive Data
Structures
Difference Table:
Non-Primitive Data
Basis Primitive Data Structure
Structure
Basic data types provided by Derived from primitive types to
Definition the programming language. handle complex data.
Can store multiple values (may
Storage Stores a single value at a time.
be structured).
More complex and can be
Complexity Simple and easy to use.
hierarchical or sequential.
Size and structure can change
Flexibility Fixed size and structure.
dynamically.
Array, Linked List, Stack,
Examples int, float, char, Boolean.
Queue, Tree, Graph.
May require more memory due
Memory Usage Requires less memory.
to pointers or links.
Linear vs Non-Linear Data Structures
1. Linear Data Structures
•Definition: Data elements are arranged in a sequential manner, one after another.
•Traversal: Single-level; each element connected to the next.
•Examples: Array, Linked List, Stack, Queue.
2. Non-Linear Data Structures
•Definition: Data elements are connected in a hierarchical or network structure.
•Traversal: Multiple paths possible; elements can be connected to multiple others.
•Examples: Tree, Graph.
Difference Table:
Feature Linear Non-Linear
Arrangement Sequential order Hierarchical or
interconnected
Traversal Path Single path Multiple paths
Examples Array, Linked List, Tree, Graph
Stack, Queue
Implementation Easy to implement More complex
Homogeneous vs
Heterogeneous Data
Structures
1. Homogeneous Data Structures
•Definition: All elements are of the same data type.
•Example: Array of integers (int arr [5] = {1, 2, 3, 4, 5}).
•Usage: Useful when data is uniform.
2. Heterogeneous Data Structures
•Definition: Elements can be of different data types.
•Example: Structure or Class containing int, float, and char members.
•Usage: Useful for grouping related but different data.
Difference Table:
Feature Homogeneous Heterogeneous
Data Type All elements have the Elements can have
same data type. different data types.
Example Array of integers, Array Structure, Class
of floats
Memory Layout Contiguous memory Memory layout depends
with equal-sized on data type sizes.
elements.
Ease of Use Easier to process using Requires handling each
Static vs Dynamic Data
1. Static Data StructuresStructures
• Definition: Size and structure are fixed at compile time.
• Memory Allocation: Done before execution (compile-time).
• Example: Array.
• Advantage: Fast access due to fixed memory location.
• Limitation: Cannot change size during execution → possible memory waste or shortage.
2. Dynamic Data Structures
• Definition: Size and structure can change at runtime.
• Memory Allocation: Done during execution (runtime).
• Example: Linked List, Dynamic Array.
• Advantage: Flexible size and efficient memory use.
• Limitation: Access may be slower due to pointer usage.
Comparison Table:
Feature Dynamic Data
Static Data Structure
Structure
Memory Allocation Compile-time allocation Runtime allocation
Flexibility Fixed size Can grow or shrink as
needed
Memory Usage May waste memory if Efficient memory usage
unused
Access Speed Faster (direct access) Slower (pointer traversal)
Examples Array Linked List, Dynamic Array
Operations on Data
Structures
1. Creation – Allocating memory and initializing the data structure.
2. Insertion – Adding new elements at a specific position.
3. Deletion – Removing existing elements.
4. Traversal – Visiting each element in a systematic manner.
5. Searching – Locating a specific element within the structure.
6. Sorting – Arranging elements in ascending or descending order.
7. Merging – Combining two or more data structures into one.
Operation Purpose Example
Creation Allocate memory int arr[10] in C
Insertion Add an element Insert 5 at position 3 in
array
Deletion Remove an element Remove 10 from linked
list
Traversal Visit each element Print all array elements
Searching Find an element Binary Search for 25
Sorting Arrange in order Bubble Sort array
Merging Combine structures Merge two sorted arrays
Reference
Reference
[Link]
[Link]
Thank
you