Lecture 1
Lecture 1
2
Importance
Without proper data structures, solving even simple
problems can become inefficient or even infeasible,
especially when the volume of data increases.
3
Why Learn Data Structures?
Optimization: Allows for faster execution of operations
like searching, sorting, or updating data.
Scalability: Helps in handling large datasets efficiently.
Problem Solving: Enables solving complex
computational problems like shortest path in a graph,
balanced parenthesis checking, etc.
4
Types of Data Structures
1. Primitive Data Structures:
• Simple data types like integers, floats, characters, and
booleans.
• Directly supported by programming languages.
2. Non-Primitive Data Structures:
More complex structures derived from primitive types.
• Linear Data Structures:
Data is arranged sequentially.
Examples: Arrays, Stacks, Queues, Linked Lists.
• Non-Linear Data Structures:
Data is arranged hierarchically or connected arbitrarily.
Examples: Trees (like family trees) and Graphs (like a city
map). 5
Examples:
• Array: Continuous block of memory storing multiple
items of the same type.
• Stack: A collection of items where the last added
item is the first to be removed (LIFO).
• Queue: A collection of items where the first added is
the first to be removed (FIFO).
• Tree: A hierarchical structure with a root node and
child nodes.
• Graph: Represents relationships between items (e.g.,
cities connected by roads).
6
Operations on Data Structures
• Insertion: Adding a new element to the data
structure.
• Deletion: Removing an element.
• Traversal: Visiting each element in the structure
(e.g., reading all items in a list).
• Searching: Finding a specific element.
• Sorting: Arranging elements in a specific order (e.g.,
ascending or descending).