mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(curriculum): add dynamic programming quiz to js v9 cert (#65995)
This commit is contained in:
@@ -3329,6 +3329,12 @@
|
|||||||
"In this lab, you will implement a function that converts an adjacency list representation of a graph into an adjacency matrix representation."
|
"In this lab, you will implement a function that converts an adjacency list representation of a graph into an adjacency matrix representation."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"quiz-dynamic-programming-js": {
|
||||||
|
"title": "Dynamic Programming Quiz",
|
||||||
|
"intro": [
|
||||||
|
"Test what you've learned about dynamic programming in JavaScript with this quiz."
|
||||||
|
]
|
||||||
|
},
|
||||||
"lecture-understanding-functional-programming": {
|
"lecture-understanding-functional-programming": {
|
||||||
"title": "Understanding Functional Programming",
|
"title": "Understanding Functional Programming",
|
||||||
"intro": [
|
"intro": [
|
||||||
|
|||||||
+234
@@ -0,0 +1,234 @@
|
|||||||
|
---
|
||||||
|
id: 699a068cfe9bb7bccf2b7ec0
|
||||||
|
title: Dynamic Programming Quiz
|
||||||
|
challengeType: 8
|
||||||
|
dashedName: quiz-dynamic-programming-js
|
||||||
|
---
|
||||||
|
|
||||||
|
# --description--
|
||||||
|
|
||||||
|
To pass the quiz, you must correctly answer at least 9 of the 10 questions below.
|
||||||
|
|
||||||
|
# --quizzes--
|
||||||
|
|
||||||
|
## --quiz--
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
What are the two essential properties that must be present in a problem for dynamic programming to be an effective solution approach?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
Fast execution time and minimal memory usage
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Recursion capability and iterative loops
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Sequential processing and parallel computation
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
Overlapping subproblems and optimal substructure
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
What is the primary difference between the memoization and tabulation approaches in dynamic programming?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
Memoization uses hash tables while tabulation uses arrays, making it more efficient.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Memoization is faster but uses more memory and CPU cycles than tabulation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Memoization can only solve simpler problems than tabulation.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
Memoization is a top-down approach using recursion, while tabulation is a bottom-up approach using iteration.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
Why do naive recursive solutions to dynamic programming problems typically have exponential time complexity?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
Because they use exponential amounts of memory to store variables.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Because they require sorting data in exponential time.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Because they must check all possible permutations of the input.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
Because each recursive call branches multiple times, causing the same subproblems to be recalculated repeatedly.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
What does optimal substructure mean in the context of dynamic programming?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
The algorithm must use the most efficient data structure available.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The solution must minimize both time and space complexity simultaneously.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The problem must have a unique, single optimal solution.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
The optimal solution can be constructed from optimal solutions to its subproblems.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
When implementing memoization, what happens when a function is called with arguments that have already been computed?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
The function recalculates the result to ensure accuracy.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The function averages the old and new results for better precision.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
An error is thrown because duplicate calculations are not allowed.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
The cached result is returned immediately without recomputation.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
What is a key advantage of using tabulation instead of memoization?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
Tabulation always requires less memory than memoization.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Tabulation can solve a broader class of problems.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Tabulation is always easier to implement and understand.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
Tabulation avoids recursion overhead and provides predictable sequential execution.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
In a bottom-up dynamic programming solution, why are base cases initialized first?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
To allocate memory for the data structure efficiently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
To prevent infinite loops in the algorithm.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
To improve the time complexity of the algorithm.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
To provide foundational values upon which all larger subproblems are built.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
How does dynamic programming transform the time complexity of problems that exhibit overlapping subproblems?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
From polynomial to logarithmic by dividing the problem efficiently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
From quadratic to linear by optimizing loop structures.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
From linear to constant by using hash tables.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
From exponential to polynomial by storing and reusing subproblem solutions.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
What trade-off does dynamic programming typically make to achieve better time complexity?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
It sacrifices code readability for faster execution.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
It requires more complex algorithms that are harder to maintain.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
It limits the size of problems that can be solved.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
It uses additional space to store intermediate results.
|
||||||
|
|
||||||
|
### --question--
|
||||||
|
|
||||||
|
#### --text--
|
||||||
|
|
||||||
|
In which scenario would dynamic programming NOT be the appropriate algorithmic approach?
|
||||||
|
|
||||||
|
#### --distractors--
|
||||||
|
|
||||||
|
When the problem requires finding an optimal solution.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
When the problem can be broken into smaller subproblems.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
When space complexity must be minimized.
|
||||||
|
|
||||||
|
#### --answer--
|
||||||
|
|
||||||
|
When subproblems are independent and don't overlap.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "Dynamic Programming Quiz",
|
||||||
|
"isUpcomingChange": true,
|
||||||
|
"blockLabel": "quiz",
|
||||||
|
"blockLayout": "link",
|
||||||
|
"dashedName": "quiz-dynamic-programming-js",
|
||||||
|
"helpCategory": "JavaScript",
|
||||||
|
"challengeOrder": [
|
||||||
|
{ "id": "699a068cfe9bb7bccf2b7ec0", "title": "Dynamic Programming Quiz" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -318,7 +318,7 @@
|
|||||||
{
|
{
|
||||||
"dashedName": "dynamic-programming",
|
"dashedName": "dynamic-programming",
|
||||||
"comingSoon": true,
|
"comingSoon": true,
|
||||||
"blocks": []
|
"blocks": ["quiz-dynamic-programming-js"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dashedName": "functional-programming",
|
"dashedName": "functional-programming",
|
||||||
|
|||||||
Reference in New Issue
Block a user