feat(curriculum): add dynamic programming quiz questions (#62418)

Co-authored-by: Sem Bauke <sem@freecodecamp.org>
Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
Co-authored-by: Ilenia M <nethleen@gmail.com>
Co-authored-by: Dario <105294544+Dario-DC@users.noreply.github.com>
This commit is contained in:
Zaira 2025-10-22 18:42:24 +05:00 committed by GitHub
parent e42a864e12
commit b84cd339c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,7 +7,7 @@ dashedName: quiz-dynamic-programming
# --description--
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
To pass the quiz, you must correctly answer at least 9 of the 10 questions below.
# --quizzes--
@ -17,439 +17,218 @@ To pass the quiz, you must correctly answer at least 18 of the 20 questions belo
#### --text--
Placeholder question
What are the two essential properties that must be present in a problem for dynamic programming to be an effective solution approach?
#### --distractors--
Placeholder distractor 1
Fast execution time and minimal memory usage
---
Placeholder distractor 2
Recursion capability and iterative loops
---
Placeholder distractor 3
Sequential processing and parallel computation
#### --answer--
Placeholder answer
Overlapping subproblems and optimal substructure
### --question--
#### --text--
Placeholder question
What is the primary difference between the memoization and tabulation approaches in dynamic programming?
#### --distractors--
Placeholder distractor 1
Memoization uses hash tables while tabulation uses arrays, making it more efficient.
---
Placeholder distractor 2
Memoization is faster but uses more memory and CPU cycles than tabulation.
---
Placeholder distractor 3
Memoization can only solve simpler problems than tabulation.
#### --answer--
Placeholder answer
Memoization is a top-down approach using recursion, while tabulation is a bottom-up approach using iteration.
### --question--
#### --text--
Placeholder question
Why do naive recursive solutions to dynamic programming problems typically have exponential time complexity?
#### --distractors--
Placeholder distractor 1
Because they use exponential amounts of memory to store variables.
---
Placeholder distractor 2
Because they require sorting data in exponential time.
---
Placeholder distractor 3
Because they must check all possible permutations of the input.
#### --answer--
Placeholder answer
Because each recursive call branches multiple times, causing the same subproblems to be recalculated repeatedly.
### --question--
#### --text--
Placeholder question
What does optimal substructure mean in the context of dynamic programming?
#### --distractors--
Placeholder distractor 1
The algorithm must use the most efficient data structure available.
---
Placeholder distractor 2
The solution must minimize both time and space complexity simultaneously.
---
Placeholder distractor 3
The problem must have a unique, single optimal solution.
#### --answer--
Placeholder answer
The optimal solution can be constructed from optimal solutions to its subproblems.
### --question--
#### --text--
Placeholder question
When implementing memoization, what happens when a function is called with arguments that have already been computed?
#### --distractors--
Placeholder distractor 1
The function recalculates the result to ensure accuracy.
---
Placeholder distractor 2
The function averages the old and new results for better precision.
---
Placeholder distractor 3
An error is thrown because duplicate calculations are not allowed.
#### --answer--
Placeholder answer
The cached result is returned immediately without recomputation.
### --question--
#### --text--
Placeholder question
What is a key advantage of using tabulation instead of memoization?
#### --distractors--
Placeholder distractor 1
Tabulation always requires less memory than memoization.
---
Placeholder distractor 2
Tabulation can solve a broader class of problems.
---
Placeholder distractor 3
Tabulation is always easier to implement and understand.
#### --answer--
Placeholder answer
Tabulation avoids recursion overhead and provides predictable sequential execution.
### --question--
#### --text--
Placeholder question
In a bottom-up dynamic programming solution, why are base cases initialized first?
#### --distractors--
Placeholder distractor 1
To allocate memory for the data structure efficiently.
---
Placeholder distractor 2
To prevent infinite loops in the algorithm.
---
Placeholder distractor 3
To improve the time complexity of the algorithm.
#### --answer--
Placeholder answer
To provide foundational values upon which all larger subproblems are built.
### --question--
#### --text--
Placeholder question
How does dynamic programming transform the time complexity of problems that exhibit overlapping subproblems?
#### --distractors--
Placeholder distractor 1
From polynomial to logarithmic by dividing the problem efficiently.
---
Placeholder distractor 2
From quadratic to linear by optimizing loop structures.
---
Placeholder distractor 3
From linear to constant by using hash tables.
#### --answer--
Placeholder answer
From exponential to polynomial by storing and reusing subproblem solutions.
### --question--
#### --text--
Placeholder question
What trade-off does dynamic programming typically make to achieve better time complexity?
#### --distractors--
Placeholder distractor 1
It sacrifices code readability for faster execution.
---
Placeholder distractor 2
It requires more complex algorithms that are harder to maintain.
---
Placeholder distractor 3
It limits the size of problems that can be solved.
#### --answer--
Placeholder answer
It uses additional space to store intermediate results.
### --question--
#### --text--
Placeholder question
In which scenario would dynamic programming NOT be the appropriate algorithmic approach?
#### --distractors--
Placeholder distractor 1
When the problem requires finding an optimal solution.
---
Placeholder distractor 2
When the problem can be broken into smaller subproblems.
---
Placeholder distractor 3
When space complexity must be minimized.
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
When subproblems are independent and don't overlap.