Question: This pseudo (Python) counts the number of ways a person could walk up a set of n stairs where they can either take 1, 2,
This pseudo (Python) counts the number of ways a person could walk up a set of n stairs where they can either take 1, 2, or 3 stairs at a time. Takes an int indicating the number of stairs to be climbed and returns an int indicating how many different ways the stairs could be traversed.
Explain what the pseudo code is doing and trace the code for countWays(5).
countWays(stairs)
if stairs < 0
return 0
else if stairs == 0
return 1
else
return countWays(stairs-1) + countWays(stairs-2) + countWays(stairs-3)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
