1. Home
  2. Explore
  3. Computer Science
  4. Dynamic Programming Course Intro

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Dynamic Programming Course Intro

  • 28Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: DP Fundamentals
Dynamic programming is a method for solving problems by breaking them down into smaller instances of the same problem that have
structure.

28 questions

  1. 1
    Dynamic programming is a method for solving problems by breaking them down into smaller instances of the same problem that have
    _____
    structure.
    Hint

    Think about subproblems that share common sub-subproblems.

    Answer

    overlapping

  2. 2
    In the context of dynamic programming,
    _____
    is the technique of storing results of expensive function calls to avoid recomputation.
    Hint

    It's like taking a memo to remember previous answers.

    Answer

    memoization

  3. 3
    Tabulation is an iterative dynamic programming approach that builds a
    _____
    from the bottom up.
    Hint

    You fill an array or grid sequentially.

    Answer

    table

  4. 4
    The classic recursive Fibonacci implementation has a time complexity of
    _____
    .
    Hint

    Think about the branching factor and tree height.

    Answer

    O(2n)O(2^n)O(2n)

  5. 5
    By adding a memo object, the time complexity of the Fibonacci function becomes
    _____
    .
    Hint

    Each n from 1 to target is computed once.

    Answer

    O(n)O(n)O(n)

  6. 6
    In the tabulation approach for Fibonacci, the table is initialized with zeros and then the value at index 1 is set to
    _____
    .
    Hint

    This seeds the base case for the first Fibonacci number.

    Answer

    1

  7. 7
    For the grid traveler problem, starting at the top-left and moving only down or right, the number of ways to travel through a 1×11 \times 11×1 grid is
    _____
    .
    Hint

    You are already at the goal.

    Answer

    1

  8. 8
    The brute force recursive grid traveler has time complexity $O(2^{\
    _____
    })$ where the exponent is m + n.
    Hint

    The tree height is the sum of the two dimensions.

    Answer

    m+nm+nm+n

  9. 9
    After memoizing grid traveler, the time complexity becomes $O(\
    _____
    )$.
    Hint

    At most m*n distinct subproblems exist.

    Answer

    m×nm \times nm×n

  10. 10
    In the can sum problem, the base case when target sum is 0 returns
    _____
    .
    Hint

    You can always make 0 by taking no numbers.

    Answer

    true

  11. 11
    The brute force can sum has a time complexity of $O(\
    _____
    )$ where m is target sum and n is array length.
    Hint

    Branching factor n, height m.

    Answer

    nmn^mnm

  12. 12
    In tabulation for can sum, the table is initialized with
    _____
    values.
    Hint

    It's a boolean problem; assume impossible until proven possible.

    Answer

    false

  13. 13
    The how sum function returns
    _____
    if the target sum cannot be generated.
    Hint

    It indicates no valid combination exists.

    Answer

    null

  14. 14
    In the memoized how sum, the space complexity is $O(\
    _____
    )$ due to storing arrays in the memo.
    Hint

    M keys, each with an array of up to m elements.

    Answer

    m2m^2m2

  15. 15
    The best sum problem is an
    _____
    problem because it asks for the shortest combination.
    Hint

    It's not just a yes/no or any combination.

    Answer

    optimization

  16. 16
    In best sum tabulation, when a candidate combination is shorter than the current one, we
    _____
    it.
    Hint

    We keep the shorter one.

    Answer

    replace

  17. 17
    In can construct, checking if a word is a prefix of the target use the JavaScript method indexOf and checks if the result equals
    _____
    .
    Hint

    A prefix starts at index 0.

    Answer

    0

  18. 18
    For can construct, the brute force time complexity is $O(\
    _____
    )$ where m is target length and n is word bank size.
    Hint

    Branching factor n, height m, plus string slicing cost.

    Answer

    nm⋅mn^m \cdot mnm⋅m

  19. 19
    In can construct tabulation, the table index i represents the substring from index 0 to i (exclusive) of the target. The value at index 0 is set to
    _____
    .
    Hint

    Empty string is always constructible.

    Answer

    true

  20. 20
    Count construct returns the
    _____
    of ways to construct the target string.
    Hint

    It's a counting problem.

    Answer

    number

  21. 21
    In count construct tabulation, the table is initialized with zeros, and index 0 is set to
    _____
    .
    Hint

    One way to make empty string.

    Answer

    1

  22. 22
    For all construct, the return value when the target is empty string is
    _____
    .
    Hint

    It's a 2D array with one empty subarray.

    Answer

    [[]][[]][[]]

  23. 23
    The all construct problem has an
    _____
    time complexity because the output itself can be exponential.
    Hint

    You have to return all combinations.

    Answer

    exponential

  24. 24
    The memorization recipe consists of first making it work using
    _____
    recursion, then making it efficient by adding a memo.
    Hint

    Start with a correct but potentially slow solution.

    Answer

    brute force

  25. 25
    In DP tabulation, the table dimensions are typically based on the size of the input that
    _____
    as we solve subproblems.
    Hint

    The input that gets smaller or larger.

    Answer

    changes

  26. 26
    When analyzing recursive space complexity, we consider the maximum
    _____
    depth.
    Hint

    The height of the recursion tree.

    Answer

    call stack

  27. 27
    In complexity analysis for DP problems, m usually denotes the
    _____
    of the target sum or the length of the target string.
    Hint

    It's a variable representing the main dimension.

    Answer

    size

  28. 28
    Drawing a
    _____
    helps visualize the recursive structure of a DP problem.
    Hint

    It shows how a problem branches into subproblems.

    Answer

    tree

1 of 28
Question 1 of 28

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent