Optimal Substructure
Everything on SkillVeris tagged Optimal Substructure — collected across the glossary, study notes, blog, and cheat sheets.
10 resources across 1 library
Interview Questions(10)
What is Dynamic Programming?
Dynamic programming is a technique for solving problems by breaking them into overlapping subproblems and storing each subproblem’s result so it is computed on…
What is Kadane's Algorithm?
Kadane's algorithm finds the maximum sum of a contiguous subarray in O(n) time and O(1) space by scanning once and, at each position, deciding whether to exten…
How Do You Prove a Greedy Algorithm is Correct?
Greedy algorithm correctness is typically proven with the exchange argument (show any optimal solution can be transformed into the greedy solution without losi…
What is the Rod Cutting Problem?
The rod cutting problem asks for the maximum revenue obtainable by cutting a rod of length n into pieces and selling each piece at a given price, and it is sol…
How Do You Solve Fibonacci with Dynamic Programming?
Naive recursive Fibonacci recomputes the same subproblems exponentially many times, costing O(2^n) time, so dynamic programming fixes this by storing each F(i)…
What is the Activity Selection Problem?
The activity selection problem is the classic greedy exercise of choosing the maximum number of non-conflicting activities from a set given each activity's sta…
What is Job Sequencing with Deadlines?
Job sequencing with deadlines is a greedy scheduling problem where each job has a profit and a deadline, only one job can run per time slot, and the goal is to…
What is the Fractional Knapsack Problem?
The fractional knapsack problem asks you to fill a capacity-limited knapsack with items that can be broken into fractions, maximizing total value by always tak…
How Does Greedy Choice Relate to Optimal Substructure?
A greedy algorithm only produces a globally optimal solution when a problem has both the greedy-choice property — a locally optimal choice at each step leads t…
Top-Down vs Bottom-Up Dynamic Programming: What is the Difference?
Top-down dynamic programming solves a problem by recursing from the original goal toward base cases, caching each subproblem result the first time it is comput…