Welcome to DSA with Python.
This book is written for people who want to actually understand data structures and algorithms, not just memorize code. The focus is simple: clear thinking, solid fundamentals, and enough practice to make concepts stick.
You are expected to know basic Python syntax. Everything else is built from scratch, step by step, with explanations that connect ideas instead of throwing formulas at you.
Syllabus Tracker¶
Arrays and Lists¶
Arrays: operations and time complexity
Lists: 1D operations
Lists: 2D operations
Arrays vs Lists
Practice Problems
Largest element
Count occurrences
Remove duplicates
Reverse a list
Where arrays and lists are used in real problems
Strings¶
Introduction and properties
Use cases
Common string functions
String manipulation and comparison
Practice Problems
Count vowels and consonants
Character frequency
Palindrome check
Anagram detection
How strings appear in algorithmic problems
Linked Lists¶
Introduction and memory model
Linked List vs Array
Types of Linked Lists
Singly Linked List
Circular Singly Linked List
Doubly Linked List
Circular Doubly Linked List
Operations
Insertion at beginning
Insertion in middle
Insertion at end
Deletion at beginning
Deletion in middle
Deletion at end
Searching
Complexity analysis
Practice Problems
Find middle element
Count nodes
Sum of nodes
Minimum and maximum element
Stacks¶
Stack concepts and operations
Implementations
Using list
Using collections
Using linked list
Practice Problems
Reverse a string
Balanced parentheses
Undo operation
Stack usage in real systems
Queues¶
Queue concepts and operations
Implementations
Using list
Using linked list
Using collections module
Queue using stacks
Practice Problems
Reverse first K elements
Ticket counter simulation
Queue usage in real systems
Searching¶
Linear Search
Binary Search
Exponential Search
Choosing the right search strategy
Sorting¶
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
Counting Sort
Complexity and stability comparison
Sorting in real applications
Recursion¶
Introduction and internal working
Recursion vs iteration
Common mistakes
Practice Problems
Factorial
Fibonacci
Print N to 1
Sum of N numbers
Count digits
Power function
When recursion is the right tool
Hashing¶
Hash functions and hash tables
Collision Handling:
Chaining
Linear probing
Quadratic probing
Load factor and complexity
Hashing with dictionaries and sets
Practice Problems
Character count
First non-repeating character
Two-sum problem
Hashing in real-world systems
Problem Solving Patterns¶
Sliding Window
Two Pointers
Fast and Slow Pointers
Prefix Sum
Hashing Pattern
Binary Search on Answer
Greedy Approach
Practice Problems
Maximum sum subarray
Longest substring without repeating characters
Anagram problems
Cycle detection
Subarray sum equals K
Top K frequent elements
Aggressive cows
Activity selection
Jump game
Trees¶
Tree terminology and properties
Traversals
Preorder
Inorder
Postorder
Level order
Binary Search Tree
Insertion
Search
Deletion
N-ary Trees
Dynamic Programming on Trees
Practice Problems
Tree depth and height
Validate BST
Lowest Common Ancestor
Kth smallest element
Maximum path sum
Tree-based problem solving
Graphs¶
Graph types and representations
BFS and DFS
Multi-source BFS
0-1 BFS
Shortest Path Algorithms
Dijkstra
Bellman-Ford
Floyd-Warshall
Advanced Algorithms
Disjoint Set Union
Prim’s Minimum Spanning Tree
Kruskal’s Minimum Spanning Tree
DAG Algorithms
Kahn’s Algorithm
Shortest paths in DAG
Longest paths in DAG
State Space Graphs
Rat in a Maze
8-Puzzle
Practice Problems
Number of islands
Cycle detection
Course scheduling
Network delay time
Cheapest flights
Rotten oranges
How to Use This Book¶
Read slowly. Implement everything yourself. If you can explain a solution without looking at code, you understand it. If not, revisit the topic.
DSA is not about speed at first. It is about clarity. Speed comes later.