Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data Structure c++ Suppose a stair way has N steps where N is a positive integer. How many different ways can you up the stair

Data Structure c++

Suppose a stair way has N steps where N is a positive integer. How many different ways can you up the stair way if, as you up, sometimes you go up one stair step with one step or you go up two stair step with one step.

Suppose the stair way has 3 steps then you can up the stair way

three different ways:

1,1,1 = 3 steps

1,2 = 3 steps

2, 1 = 3 steps

Suppose the stair way has 4 steps then you can up the stair way

five different ways

1,1,1,1 = 4 steps

1,1,2 = 4 steps

1,2,1 = 4 steps

2, 1,1, = 4 steps

2,2 = 4 steps

Write a recursive function to solve the problem.

The function, f, will contain statements that will look like,

...

return f(N-1) + f(N-2)

Write a program to test the function with many, different values of N.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions