AdvancedNumeric answer
Climbing a staircase · Part 3 of 3
You climb a staircase one move at a time. Each move climbs a number of steps from an allowed set, and two climbs differ if their sequences of moves differ, so 1 then 2 and 2 then 1 count separately.
Back to moves of 1 or 2. An uncached recursive ways(n) returns 1 when n <= 1 and otherwise returns ways(n - 1) + ways(n - 2). How many calls, the first included, does ways(20) make?
Answer with a number. Fractions, powers and expressions like 23/6 or C(52,5) are read correctly in practice.
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Learn the method
More data structures and algorithms questions
- You need the 100 largest values from a stream of 10⁹ numbers you cannot store.Foundation
- How many times does the inner body run in for i in range(1000): for j in range(i): body()?Foundation
- What does the recurrence T(n) = 2T(n/2)+O(n) solve to?Applied
- A hot-path buffer is a dynamic array with O(1) amortised push.Applied
- What does the recurrence T(n) = 4T(n/2)+Θ(n²) solve to?Applied
- A dynamic array starts with capacity 1 and doubles when full, copying all elements.Applied