Unit

Data Structure and Algorithm IV

Advanced Algorithms: Graphs, DP (Dynamic Programming) – Practice with Curated LeetCode Questions
Graph
Graph Algorithm
Dynamic Programming

Duration

6 weeks

random shape
thumbnail image

Introduction

Welcome to Data Structures and Algorithms IV. This unit covers two powerful problem-solving techniques: graph algorithms and dynamic programming. You'll learn how to break down complex problems into simpler parts and build efficient solutions step by step. Through practice with carefully selected LeetCode questions, you'll develop the skills to recognize common patterns, implement key algorithms, and optimize your code. These techniques are essential for technical interviews at top tech companies and will help you solve challenging programming problems in your career.

Prerequisites

  • Complete Data Structure and Algorithm III Unit.

Skills Covered

In this unit, we are going to cover the following topics.
  • Graphs: Master traversals (DFS/BFS), shortest-path (Dijkstra’s, Bellman-Ford), MSTs (Prim’s, Kruskal’s), topological sorting, and Union-Find for dynamic connectivity.
  • Dynamic Programming: Design optimal substructures (memoization/tabulation) for knapsack, string edits, and sequence alignment.

Recommended Study Material

Graph
Learn the basic of Graph data structure and its representation.
Graph
Data Structure

Duration:

10 minutes

Breath-first search
Learn to use breath first search and its implementation.
Graph
Algorithm

Duration:

30 minutes

Depth-first search
Learn to use breath first search and its implementation.
Graph
Algorithm

Duration:

30 minutes

Topological Sort
Learn about Topological sort and its implementation.
Graph
Algorithm
Sorting

Duration:

1 hour

Dijkstra's Algorithm
Learn to find single source shortest path using Dijkstra algorithm.
Graph
Algorithm

Duration:

1 hour

Bellman-Ford Algorithm
Learn to find single source shortest path using Dijkstra algorithm.
Graph
Algorithm

Duration:

1 hour

Prim's Algorithm
Learn to find minimum spannig tree using Prim’s algorithm.
Graph
Algorithm

Duration:

1 hour

Kruskal's Algorithm
Learn to find minimum spannig tree using Kruskal’s algorithm.
Graph
Algorithm

Duration:

30 minutes

Disjoint Sets
Design disjoint sets which supports makeSet, union and findSet operations.
Graph
Algorithm

Duration:

1 hour

Dynamic Programming
Learn the basics of memoization and dynamic programming.
Dynamic Programming

Duration:

30 minutes

Practice Problems

StatusBookmarkProblemDifficultyTagsSolution
Island PerimeterEasy
Find the Town JudgeEasy
Number of IslandsMedium
Max Area of IslandMedium
Time Needed to Inform All EmployeesMedium
All Paths From Source to TargetMedium
Clone GraphMedium
Directed Graph CycleMedium
Undirected Graph CycleMedium
Is Graph Bipartite?Medium
All Nodes Distance K in Binary TreeMedium
Employee ImportanceMedium
Surrounded RegionsMedium
Pacific Atlantic Water FlowMedium
Rotting OrangesMedium
01 MatrixMedium
Open the LockMedium
Evaluate DivisionMedium
Graph Valid TreeMedium
Walls and GatesMedium
Course ScheduleMedium
Course Schedule IIMedium
Course Schedule IVMedium
Find Eventual Safe StatesMedium
Minimum Height TreesMedium
Redundant ConnectionMedium
Number of ProvincesMedium
Number of Connected Components in an Undirected GraphMedium
Accounts MergeMedium
Network Delay TimeMedium
Path With Minimum EffortMedium
Path with Maximum ProbabilityMedium
Min Cost to Connect All PointsMedium
Cheapest Flights Within K StopsMedium
Divide Nodes Into the Maximum Number of GroupsHard
Bus RoutesHard
Word LadderHard
Making A Large IslandHard
Sort Items by Groups Respecting DependenciesHard
Alien DictionaryHard
Minimize Malware SpreadHard
Swim in Rising WaterHard
Find Critical and Pseudo-Critical Edges in Minimum Spanning TreeHard
Reconstruct ItineraryHard
Valid Arrangement of PairsHard
Climbing Stairs Easy
Min Cost Climbing StairsEasy
N-th Tribonacci NumberEasy
House RobberMedium
House Robber IIMedium
Longest Palindromic SubstringMedium
Palindromic SubstringsMedium
Decode WaysMedium
Coin ChangeMedium
Maximum Product SubarrayMedium
Word BreakMedium
Longest Increasing SubsequenceMedium
Partition Equal Subset SumMedium
Combination Sum IVMedium
Integer BreakMedium
Unique PathsMedium
Unique Paths IIMedium
Minimum Path SumMedium
Longest Common SubsequenceMedium
Last Stone Weight IIMedium
Best Time to Buy and Sell Stock with CooldownMedium
Coin Change IIMedium
Perfect SquaresMedium
House Robber IIIMedium
Target SumMedium
Interleaving StringMedium
Stone GameMedium
Stone Game IIMedium
Edit DistanceMedium
Egg Drop With 2 Eggs and N FloorsMedium
Super Egg DropHard
Burst BalloonsHard
Maximum Profit in Job SchedulingHard
Word Break IIHard
Palindrome Partitioning IIHard
Regular Expression MatchingHard
Wildcard MatchingHard

Credit

The problem set is carefully curated from Neetcode and AlgoMaster, supplemented with additional practice questions for comprehensive coverage.

Contributor(s)

John Doe

Founder and Fullstack Developer at freeCodeProject.org

Created this Unit with curated list of questions for practice.