CSUC201 · SEMESTER III
Introduction to Data Structures
and Algorithms
Fundamentals of Data Structures and Algorithms
Prof. Siddharth Shah
Programs Trees Graphs Code AI
“Efficient programs begin with efficient data organization.”
WA R M - U P
How Does Technology Respond So Quickly?
Think about these everyday situations.
Search Engines Navigation Apps Social Networks Music Streaming AI Assistants
Find the right webpage Calculate the fastest route Suggest people you may Play the next song Generate answers within
among billions in less than instantly. know. immediately. seconds.
a second.
The answer lies in Data Structures and Algorithms (DSA).
CSUC201 · Fundamentals of Data Structures and Algorithms
The answer
2
M O T I V AT I O N
Why Should We Study DSA?
Computer hardware is becoming faster every year.
But a fast computer cannot compensate for an inefficient
algorithm.
Searching one million records
Key Message
Linear Search Binary Search
50,000×
1,000,000 ≈20 Choosing the right algorithm can improve
performance by up to 50,000 times — even on
comparisons comparisons
the very same computer.
CSUC201 · Fundamentals of Data Structures and Algorithms 3
REAL-WORLD MAPPING
Every Application Uses Data Structures
Navigation Apps File System
Graphs, Priority Queue Tree
Messaging Apps Database Engines
Queue, Hash Tables B+ Tree
Web Browser AI Models
Stack Arrays, Matrices, Graphs
Music Playlists Linked List (ordered
navigation)
CSUC201 · Fundamentals of Data Structures and Algorithms 4
IN-CLASS ACTIVITY
Arrange Yourselves by Height
The Activity
Students physically arrange themselves in order of height, then
reflect on how they did it.
Why did everyone stand in order?
1 Compare heights
Because the data became organized.
2 Move to the correct position
3 Exchange places as needed
That organized arrangement is a Data
Structure.
That sequence of steps is an Algorithm.
CSUC201 · Fundamentals of Data Structures and Algorithms 5
CONCEPT BUILDING
From Data to Data Structures
What is Data?
Data represents raw facts or values.
Student Marks Roll Numbers Names Images
Audio GPS Coordinates Bank Transactions
Is storing data enough? No — we must organize it.
A Data Structure is a systematic way of organizing and storing data so that it can be accessed and modified efficiently.
CSUC201 · Fundamentals of Data Structures and Algorithms 6
ANALOGY
The Library Analogy
Imagine a library with 50,000 books.
Without Organization With Organization
Books are piled randomly. Rack Number
↓
Shelf Number
Finding one book may take several hours.
↓
Book Number
Finding takes only a few seconds.
CSUC201 · Fundamentals of Data Structures and Algorithms 7
CONCEPT BUILDING
What is an Algorithm?
Suppose someone asks: “Bring the book Data Structures and Algorithms.”
Method 1 Method 2 Defi nition
An Algorithm is a finite sequence of
Use the library catalogue — go well-defined instructions to solve a
Check every book, one by one.
directly to Rack → Shelf → Book.
problem.
Characteristics of a Good Algorithm
Finite Unambiguous Correct Input Output
CSUC201 · Fundamentals of Data Structures and Algorithms 8
DISTINCTION
Data Structure vs Algorithm
Data Structure Algorithm
Organizes data Processes data
Focuses on storage Focuses on procedure
Determines efficiency of access Determines efficiency of processing
Example: Array Example: Binary Search
Data Structure determines how data is organized and stored,
while an Algorithm determines how that data is processed to solve a problem.
CSUC201 · Fundamentals of Data Structures and Algorithms 9
P R O G R A M S = D ATA S T R U C T U R E S + A L G O R I T H M S
“Programs = Data Structures + Algorithms”
— Niklaus Wirth, creator of Pascal
Today we can extend this idea:
Efficient Efficient Data Efficient
Program = Structure + Algorithm
Key Message: Even the best algorithm performs poorly if the data is organized badly.
CSUC201 · Fundamentals of Data Structures and Algorithms 10
TA X O N O M Y
Classification of Data Structures
CSUC201 · Fundamentals of Data Structures and Algorithms 11
O P E R AT I O N S
Common Data Structure Operations
Every data structure supports some combination of these operations.
Traversal Searching Insertion
Visit every element Find an element Add new data
Deletion Sorting Merging
Remove data Arrange data Combine collections
CSUC201 · Fundamentals of Data Structures and Algorithms 12
UNDER THE HOOD
How Does the Computer Store Data?
The computer stores everything in memory. Each address stores one value.
100 104 108 112 116 120
Memory Address Space
Different data structures organize these memory locations differently — some sequentially (arrays), some scattered and linked
(linked lists), and some hierarchically (trees).
CSUC201 · Fundamentals of Data Structures and Algorithms 13
LINEAR STRUCTURES
Arrays — Sequential Memory
A[0] A[1] A[2] A[3] A[4]
15 22 31 44 50
100 104 108 112 116
Properties Access Example
A[3]
Contiguous memory
Fixed size
Time Complexity
Fast indexing
Excellent cache performance O(1) — constant time, regardless of
array size
CSUC201 · Fundamentals of Data Structures and Algorithms 14
LINEAR STRUCTURES
Linked Lists — Dynamic Memory
Nodes can exist anywhere in memory, connected by pointers.
15 • 22 • 31 X
Each node stores: Data + Pointer (address of the next node)
Advantages Disadvantages
Dynamic size
Sequential access only
Easy insertion
Extra memory for pointers
Easy deletion
CSUC201 · Fundamentals of Data Structures and Algorithms 15
CO M PA R I S O N
Array vs Linked List
Feature Array Linked List
Memory Continuous Scattered
Access Random Sequential
Insert Slow Fast
Delete Slow Fast
Size Fixed Dynamic
Discussion: Which one would you choose for a music playlist — and why?
CSUC201 · Fundamentals of Data Structures and Algorithms 16
SCALING UP
Why Efficiency Matters
10 10 Million
students — searching is easy users — can we still use the same method?
No. As data grows, algorithm efficiency becomes increasingly important.
This leads us to Algorithm Analysis →
CSUC201 · Fundamentals of Data Structures and Algorithms 17
COURSE ROADMAP
Where Will We Use These?
Array Linked List Stack Queue
Images Playlist Browser History Railway Reservation
Tree Heap Hash Table Graph
File System CPU Scheduling Contacts Search Navigation Apps
Throughout this course:
Arrays Linked Lists Stacks Queues Trees Hash Tables Graphs Algorithms
CSUC201 · Fundamentals of Data Structures and Algorithms 19
WRAP-UP
Summary and Reflection
What is Data What is a Data Structure
What is an Algorithm Difference between them
Classification of Data Structures Arrays and Linked Lists
Think Before Next Class
Why can't faster hardware replace better algorithms?
Which data structure does a navigation app primarily use?
Why is Binary Search much faster than Linear Search?
Homework
Find 10 real-world applications of Data Structures.
Identify the most suitable data structure for each and justify in 1–2 sentences.
Write 150–200 words: “Why is algorithm efficiency more important than a faster computer?”