DATA STRUCTURE AND
ALGORITHM
Lesson 1
What is Data Structure?
• A data structure is a way of organizing and
storing data in a computer so that it can be
accessed and used efficiently. It refers to the
logical or mathematical representation of
data, as well as the implementation in a
computer program.
WHY DATA STRUCTURE IS
IMPORTANT?
• To organize and manage data effectively
• To improve the performance of algorithms
• To handle large amounts of data efficiently
• To solve complex problems faster
Classification Of Data Structure
Data structures can be classified into two broad
categories:
• Linear Data Structure:
A data structure in which data elements are arranged
sequentially or linearly, where each element is attached to its
previous and next adjacent elements, is called a linear data
structure. Examples are array, stack, queue, etc.
• Non-linear Data Structure:
Data structures where data elements are not placed
sequentially or linearly are called non-linear data structures.
Examples are trees and graphs.
ADVANTAGE OF DATA
STRUCTURE
The use of data structures provides several
advantages, including:
• Efficiency:
Data structures allow for efficient storage and retrieval of data, which is
important in applications where performance is critical.
• Flexibility:
Data structures provide a flexible way to organize and store data,
allowing for easy modification and manipulation.
• Reusability
Data structures can be used in multiple programs and applications,
reducing the need for redundant code.
• Maintainability
TYPES OF DATA STRUCTURE
Data Structure Description Simple Example
Stores elements in a fixed-size,
Array [10, 20, 30, 40]
ordered list
A sequence of elements where each
Linked List 10 → 20 → 30 → null
points to the next
Like stacking plates: last plate on
Stack Follows Last In, First Out (LIFO)
top is removed first
Queue Follows First In, First Out (FIFO) Like a line in a grocery store
Hierarchical structure with parent-
Tree Family tree
child relationships
Graph Set of connected nodes (vertices) Social network, maps
Stores key-value pairs for quick Like a dictionary: 'apple': 1,
Hash Table
access 'banana': 2