3-Month Data Structures & Algorithms
Study Plan (C++/Java)
Overview
Duration: 12 weeks (3 months)
Focus: Problem-solving oriented approach
Theory Resource: Algorithms in C++ by Robert Sedgewick
Practice Platforms: LeetCode, CodeChef, SPOJ
Month 1: Foundation Building
Week 1: Arrays & Basic Math
Sedgewick Chapters: Chapter 1 (Fundamentals), Chapter 2.1-2.2 (Elementary Sorts)
Theory Focus:
● Array manipulation techniques
● Two-pointer technique
● Sliding window
● Basic mathematical operations
Problems to Solve: 15-20 problems
LeetCode Problems:
● Two Sum - Easy
● Best Time to Buy and Sell Stock - Easy
● Maximum Subarray - Medium
● Product of Array Except Self - Medium
● Container With Most Water - Medium
● 3Sum - Medium
● Rotate Array - Medium
● Move Zeroes
● Reverse String
● Valid Palindrome
CodeChef Problems:
● FLOW001 - Add Two Numbers
● FLOW002 - Find Remainder
● INTEST - Enormous Input Test
● FCTRL - Factorial
● COINS - Bytelandian gold coins
SPOJ Problems:
● PRIME1 - Prime Generator
● ADDREV - Adding Reversed Numbers
● PALIN - The Next Palindrome
Week 2: Strings & Pattern Matching
Sedgewick Chapters: Chapter 5.1-5.2 (String Sorts, Tries)
Theory Focus:
● String manipulation
● KMP algorithm basics
● Hashing for strings
Problems to Solve: 12-15 problems
LeetCode Problems:
● Valid Anagram - Easy
● Longest Common Prefix - Easy
● Valid Palindrome - Easy
● Group Anagrams - Medium
● Longest Substring Without Repeating Characters - Medium
● Palindromic Substrings - Medium
CodeChef Problems:
● LAPIN - Lapindromes
● CHEFSQ - Chef and Subsequences
SPOJ Problems:
● RPLC - Replace
● ANARC05B - The Double HeLiX
Week 3: Recursion & Backtracking
Sedgewick Chapters: Chapter 1.1 (Basic Programming Model - Recursion section)
Theory Focus:
● Recursion fundamentals
● Backtracking technique
● Divide and conquer approach
Problems to Solve: 12-15 problems
LeetCode Problems:
● Fibonacci Number - Easy
● Power of Two - Easy
● Generate Parentheses - Medium
● Permutations - Medium
● Subsets - Medium
● N-Queens - Hard
● Sudoku Solver - Hard
CodeChef Problems:
● NOKIA - Nokia
● MARCHA1 - Marcha1
SPOJ Problems:
● PARTY - Party Schedule
● QUEEN - Aggressive cows
Week 4: Sorting & Searching
Sedgewick Chapters: Chapter 2.1-2.5 (Elementary Sorts, Mergesort, Quicksort, Priority
Queues, Applications)
Theory Focus:
● All sorting algorithms
● Binary search and variations
● Time complexity analysis
Problems to Solve: 15-18 problems
LeetCode Problems:
● Binary Search - Easy
● First Bad Version - Easy
● Search Insert Position - Easy
● Find First and Last Position of Element in Sorted Array - Medium
● Search in Rotated Sorted Array - Medium
● Merge Intervals - Medium
● Kth Largest Element in an Array - Medium
● Insert Interval
● Meeting Rooms II
● Non-overlapping Intervals
● Task Scheduler
● Merge Sorted Array
● Sort Colors
● First Missing Positive
● Kth Largest Element in an Array
● Sort List
Searching :
● Search in Rotated Sorted Array
● Find Peak Element
● Search a 2D Matrix
● Find Minimum in Rotated Sorted Array
● Median of Two Sorted Arrays
CodeChef Problems:
● STFOOD - Student Food
● CIELAB - Ciel and A-B Problem
SPOJ Problems:
● AGGRCOW - Aggressive cows
● PRATA - Roti Prata
Month 2: Data Structures Deep Dive
Week 5: Stack & Queue
Sedgewick Chapters: Chapter 1.3 (Bags, Queues, and Stacks)
Theory Focus:
● Stack operations and applications
● Queue operations and applications
● Monotonic stack/queue
Problems to Solve: 12-15 problems
LeetCode Problems:
● Valid Parentheses - Easy
● Implement Queue using Stacks - Easy
● Min Stack - Medium
● Daily Temperatures - Medium
● Next Greater Element I - Easy
● Largest Rectangle in Histogram - Hard
● Evaluate Reverse Polish Notation
CodeChef Problems:
● MAXDIFF - Maximum Difference
● COMPILER - Compiler
SPOJ Problems:
● HISTOGRA - Largest Rectangle in Histogram
● STPAR - Street Parade
Week 6: Linked Lists
Sedgewick Chapters: Chapter 1.3 (Linked Lists section)
Theory Focus:
● Singly and doubly linked lists
● Fast and slow pointer technique
● List manipulation
Problems to Solve: 12-15 problems
LeetCode Problems:
● Reverse Linked List - Easy
● Merge Two Sorted Lists - Easy
● Linked List Cycle - Easy
● Remove Nth Node From End of List - Medium
● Add Two Numbers - Medium
● Copy List with Random Pointer - Medium
● Palindrome Linked List
CodeChef Problems:
● LEVY - Levy's Conjecture
SPOJ Problems:
● CLLIST - Circular List
Week 7: Trees (Binary Trees)
Sedgewick Chapters: Chapter 3.2 (Binary Search Trees)
Theory Focus:
● Binary tree traversals
● Binary search trees
● Tree construction and manipulation
Problems to Solve: 15-18 problems
LeetCode Problems:
● Binary Tree Inorder Traversal - Easy
● Maximum Depth of Binary Tree - Easy
● Same Tree - Easy
● Validate Binary Search Tree - Medium
● Binary Tree Level Order Traversal - Medium
● Construct Binary Tree from Preorder and Inorder Traversal - Medium
● Lowest Common Ancestor of a Binary Tree - Medium
● Invert Binary Tree
● Maximum Depth of Binary Tree
● Validate Binary Search Tree
● Binary Tree Level Order Traversal
CodeChef Problems:
● TREEROOT - Tree Root
SPOJ Problems:
● PT07Y - Is it a tree
● BTCODE - Binary Tree Codes
Week 8: Heaps & Hash Tables
Sedgewick Chapters: Chapter 2.4 (Priority Queues), Chapter 3.4 (Hash Tables)
Theory Focus:
● Heap operations (min/max heap)
● Hash table implementations
● Collision resolution techniques
Problems to Solve: 12-15 problems
LeetCode Problems:
● Kth Largest Element in an Array - Medium
● Top K Frequent Elements - Medium
● Find Median from Data Stream - Hard
● Two Sum - Easy (Hash table approach)
● 4Sum II - Medium
CodeChef Problems:
● CHEFHEAP - Chef and Heap
● KQUERY - K-query
SPOJ Problems:
● KQUERYO - K-query Online
Month 3: Advanced Topics & Graph Algorithms
Week 9: Graph Fundamentals (BFS/DFS)
Sedgewick Chapters: Chapter 4.1-4.2 (Undirected Graphs, Directed Graphs)
Theory Focus:
● Graph representations
● BFS and DFS traversals
● Connected components
● Topological sorting
Problems to Solve: 15-18 problems
LeetCode Problems:
● Number of Islands - Medium
● Clone Graph - Medium
● Course Schedule - Medium
● Pacific Atlantic Water Flow - Medium
● Word Ladder - Hard
● Alien Dictionary - Hard (Premium)
CodeChef Problems:
● FIRESC - Fire Escape Routes
● ABCPATH - ABC Path
SPOJ Problems:
● BUGLIFE - A Bug's Life
● PATHC - Count on a path
● TOPOSORT - Topological Sorting
Week 10: Advanced Graph Algorithms
Sedgewick Chapters: Chapter 4.4 (Shortest Paths)
Theory Focus:
● Dijkstra's algorithm
● Bellman-Ford algorithm
● Floyd-Warshall algorithm
● MST (Kruskal's and Prim's)
Problems to Solve: 12-15 problems
LeetCode Problems:
● Network Delay Time - Medium
● Cheapest Flights Within K Stops - Medium
● Min Cost to Connect All Points - Medium
● Path with Maximum Probability - Medium
CodeChef Problems:
● DISJOINT - Disjoint Set Union
SPOJ Problems:
● SHPATH - The Shortest Path
● MST - Minimum Spanning Tree
● HIGHWAYS - Highways
Week 11: Dynamic Programming Fundamentals
Sedgewick Chapters: Chapter 6 (Context - though Sedgewick has limited DP coverage)
Theory Focus:
● Memoization vs tabulation
● 1D and 2D DP problems
● Classic DP patterns
Problems to Solve: 15-20 problems
LeetCode Problems:
● Climbing Stairs - Easy
● House Robber - Medium
● Coin Change - Medium
● Longest Increasing Subsequence - Medium
● Unique Paths - Medium
● Edit Distance - Hard
● Maximum Product Subarray - Medium
● Word Break
● Knapsack Problem
● Matrix Chain Multiplication
● Longest Common Subsequence
CodeChef Problems:
● MIXTURES - Mixtures
● COINS - Bytelandian gold coins
● PARTY - Party Schedule
SPOJ Problems:
● ACODE - Alphacode
● COINS - Bytelandian gold coins
● LIS - Longest Increasing Subsequence
Week 12: Advanced DP & Review
Theory Focus:
● Advanced DP patterns
● State machine DP
● Bitmask DP basics
● Review weak areas
Problems to Solve: 12-15 problems + Review
LeetCode Problems:
● Best Time to Buy and Sell Stock with Transaction Fee - Medium
● Palindromic Substrings - Medium
● Longest Palindromic Subsequence - Medium
● Minimum Path Sum - Medium
● Target Sum - Medium
CodeChef Problems:
● ALTARAY - Alternating Array
● STEPS - Steps
SPOJ Problems:
● BORW - Black or White
● MCOINS - Coins Game
Practice:
● Advanced Graph Algorithms:
● Problems to solve: 15
● Dijkstra's Algorithm
● Bellman-Ford Algorithm
● Floyd-Warshall Algorithm
● Minimum Spanning Tree
● Topological Sorting
● Miscellaneous Topics:
● Problems to solve: 15
● Bit Manipulation
● Tries
● Segment Trees
● Fenwick Trees
● Suffix Arrays
Weekly Schedule Template
Monday-Tuesday: Theory (Sedgewick chapters)
Wednesday-Friday: Problem solving (Easy to Medium)
Saturday: Hard problems and review
Sunday: Weekly contest on CodeChef/LeetCode + weak area practice
Problem Distribution Per Topic
● Arrays & Math: 15-20 problems
● Strings: 12-15 problems
● Recursion & Backtracking: 12-15 problems
● Sorting & Searching: 15-18 problems
● Stack & Queue: 12-15 problems
● Linked Lists: 12-15 problems
● Trees: 15-18 problems
● Heaps & Hash Tables: 12-15 problems
● Graph BFS/DFS: 15-18 problems
● Advanced Graphs: 12-15 problems
● DP Fundamentals: 15-20 problems
● Advanced DP: 12-15 problems
Total: ~170-200 problems over 3 months
Progress Tracking Tips
1. Maintain a spreadsheet to track solved problems
2. Note the time taken for each problem
3. Review and re-solve problems you struggled with
4. Participate in weekly contests
5. Focus more time on topics where you're weak
Additional Resources
● CP-Algorithms for advanced topics not covered in Sedgewick
● GeeksforGeeks for implementation references
● Codeforces for additional contest practice
● InterviewBit for structured interview preparation
Success Metrics
● Solve 80% of Easy problems within 15 minutes
● Solve 60% of Medium problems within 30 minutes
● Solve 30% of Hard problems within 45 minutes
● Consistent participation in weekly contests
● Improvement in contest rankings over time
Month 1: Foundations and Basic Data Structures
Week 1-2: Introduction and Basic Data Structures
Theory:
● Read Chapters 1-3 from "Algorithms in C++" by Robert Sedgewick to get an
introduction to algorithms, union-find, and analysis of algorithms.
Practice:
● Arrays and Strings:
● Problems to solve: 10
● Two Sum
● Best Time to Buy and Sell Stock II
● Move Zeroes
● Reverse String
● Valid Palindrome
● Linked Lists:
● Problems to solve: 10
● Reverse Linked List
● Merge Two Sorted Lists
● Linked List Cycle
● Remove Nth Node From End of List
● Palindrome Linked List
Week 3-4: Stacks, Queues, and Basic Sorting Algorithms
Theory:
● Read Chapters 4-5 from "Algorithms in C++" by Robert Sedgewick to understand
stacks, queues, and basic sorting algorithms.
Practice:
● Stacks and Queues:
● Problems to solve: 10
● Valid Parentheses
● Min Stack
● Implement Queue using Stacks
● Evaluate Reverse Polish Notation
● Daily Temperatures
● Sorting Algorithms:
● Problems to solve: 10
● Merge Sorted Array
● Sort Colors
● First Missing Positive
● Kth Largest Element in an Array
● Sort List
Month 2: Intermediate Data Structures and Algorithms
Week 5-6: Trees and Graphs
Theory:
● Read Chapters 6-7 from "Algorithms in C++" by Robert Sedgewick to understand
trees and graphs.
Practice:
● Trees:
● Problems to solve: 15
● Invert Binary Tree
● Maximum Depth of Binary Tree
● Validate Binary Search Tree
● Binary Tree Level Order Traversal
● Lowest Common Ancestor of a Binary Tree
● Graphs:
● Problems to solve: 15
● Number of Islands
● Clone Graph
● Course Schedule
● Word Ladder
● Graph Valid Tree
Week 7-8: Advanced Sorting and Searching
Theory:
● Read Chapters 8-9 from "Algorithms in C++" by Robert Sedgewick to understand
advanced sorting and searching algorithms.
Practice:
● Advanced Sorting:
● Problems to solve: 10
● Merge Intervals
● Insert Interval
● Meeting Rooms II
● Non-overlapping Intervals
● Task Scheduler
● Searching:
● Problems to solve: 10
● Search in Rotated Sorted Array
● Find Peak Element
● Search a 2D Matrix
● Find Minimum in Rotated Sorted Array
● Median of Two Sorted Arrays
Month 3: Advanced Topics and Problem Solving
Week 9-10: Dynamic Programming
Theory:
● Read Chapter 10 from "Algorithms in C++" by Robert Sedgewick to understand
dynamic programming.
Practice:
● Dynamic Programming:
● Problems to solve: 20
● Climbing Stairs
● House Robber
● Coin Change
● Longest Increasing Subsequence
● Word Break
● Knapsack Problem
● Matrix Chain Multiplication
● Edit Distance
● Maximum Product Subarray
● Unique Paths
Week 11-12: Advanced Graph Algorithms and Miscellaneous Topics
Theory:
● Read Chapters 11-12 from "Algorithms in C++" by Robert Sedgewick to
understand advanced graph algorithms.
Practice:
● Advanced Graph Algorithms:
● Problems to solve: 15
● Dijkstra's Algorithm
● Bellman-Ford Algorithm
● Floyd-Warshall Algorithm
● Minimum Spanning Tree
● Topological Sorting
● Miscellaneous Topics:
● Problems to solve: 15
● Bit Manipulation
● Tries
● Segment Trees
● Fenwick Trees
● Suffix Arrays
Additional Resources
● CodeChef: CodeChef Practice
● SPOJ: SPOJ Problems
● LeetCode: LeetCode Explore
This plan should give you a structured approach to mastering Data Structures and
Algorithms in C++ with a strong focus on problem-solving. Good luck!