Write a recursive method waystoclimb

Assignment Help Computer Engineering
Reference no: EM132105136

In this problem, the scenario we are evaluating is the following: You're standing at the base of a staircase and are heading to the top.

A small stride will move up one stair, and a large stride advances two. You want to count the number of ways to climb the entire staircase based on different combinations of large and small strides.

For example, a staircase of three steps can be climbed in three different ways: three small strides, one small stride followed by one large stride, or one large followed by one small.

Write a recursive method waysToClimb that takes a non-negative integer value representing a number of stairs and prints each unique way to climb a staircase of that height, taking strides of one or two stairs at a time.

Your method should output each way to climb the stairs on its own line, using a 1 to indicate a small stride of 1 stair, and a 2 to indicate a large stride of 2 stairs. For example, the call of waysToClimb(3) should produce the following output:

[1, 1, 1] [1, 2] [2, 1]
The call of waysToClimb(4) should produce the following output:

[1, 1, 1, 1] [1, 1, 2] [1, 2, 1] [2, 1, 1] [2, 2]
The order in which you output the possible ways to climb the stairs is not important, so long as you list the right overall set of ways.

There are no ways to climb zero stairs, so your method should produce no output if 0 is passed. Do not use any loops in solving this problem.

Reference no: EM132105136

Questions Cloud

Describe how the integrated lessons learned process : Describe how the integrated lessons learned process would be conducted at project completion.
Describe how the alignment between a project objectives : Describe how the alignment between a project's objectives and corporate objectives would be maintained throughout the project lifecycle
Perform the steps of abstraction and refinement on them : Bees shall spawn from the hive when the user interacts with the hive. Bees shall be able to move from the hive to a flower.
Ethical dilemma that a project team member might face : Discuss how the project manager could aid in avoiding or resolving such a dilemma. Discuss where this dilemma falls within PMI codes.
Write a recursive method waystoclimb : You want to count the number of ways to climb the entire staircase based on different combinations of large and small strides.
What are project reports : What are project reports and how does help with me with report writing in the future?
What are the four precedence diagram methods : What are the four precedence diagram methods? Give an example of each.
Search a bitmap in rgb format and count the number : You are to search a bitmap in RGB format and count the number of pixels which match a set of colors.
What is the impact of crashing on the project : When should a project crash? What is the impact of crashing on the project, which affects compressing the project's schedule?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd