Problem Solving with Go course

Recursion and DPQuiz: Recursion and DP

Problem Solving with Go

Display

Theme

Recursion and DP · Quiz

Quiz: Recursion and DP

Check what you know about recursion, memoization, counting combinations, bottom-up tables and DP on a grid. Answer every question below.

  1. Question 1 of 6What goes wrong with this function?
    func countdown(n int) int {
    	return countdown(n-1) + 1
    }
  2. Question 2 of 6Why is plain recursion for the number of slab patterns so slow for n = 50?
  3. Question 3 of 6Which line declares a closure that can call itself?
  4. Question 4 of 6A memoised recursion depends on a position (row and column) and the number of keys collected. What's a good memo key?
  5. Question 5 of 6Coins of 1 and 2. How many ways make 4 if order doesn't matter, and how many if it does?
  6. Question 6 of 6In a bottom-up table for the cheapest way to buy exactly x litres, best[x] is -1 when it can't be done. Why must the loop skip best[x-size] when it is -1?