Question 4 - Algorithm Design Imagine you are a treasure hunter standing at one side of the river. There are n (a positive integer) stones on the river. They are aligned on a straight line and at the nth stone, there is treasure waiting for you. Your target is to reach the nth stone. For each move, you have the choice of either walking (move one stone ahead) or leaping (move two stones ahead). Also, you are not allowed to travel backwards. Design an algorithm that calculates the number of ways (sequences of walks/leaps) that get you to the treasure stone. You should clearly explain the algorithm and demonstrate the correctness of the algorithm with a complete proof. 1

icon
Related questions
Question
Question 4 - Algorithm Design
Imagine you are a treasure hunter standing at one side of the river. There are n (a positive
integer) stones on the river. They are aligned on a straight line and at the nth stone, there is
treasure waiting for you. Your target is to reach the nth stone. For each move, you have the
choice of either walking (move one stone ahead) or leaping (move two stones ahead). Also, you
are not allowed to travel backwards. Design an algorithm that calculates the number of ways
(sequences of walks/leaps) that get you to the treasure stone. You should clearly explain the
algorithm and demonstrate the correctness of the algorithm with a complete proof.
Here is an example. For n =
1
5, there are 8 ways:
Method 1: walk → walk → walk → walk → walk
Method 2: walk → walk → walk → leap
Method 3: walk → walk → leap → walk
Method 4: walk → leap → walk →
walk
walk
Method 5: leap → walk → walk →
Method 6: leap → leap walk
Method 7: leap → walk → leap
Method 8: walk → leap leap
Transcribed Image Text:Question 4 - Algorithm Design Imagine you are a treasure hunter standing at one side of the river. There are n (a positive integer) stones on the river. They are aligned on a straight line and at the nth stone, there is treasure waiting for you. Your target is to reach the nth stone. For each move, you have the choice of either walking (move one stone ahead) or leaping (move two stones ahead). Also, you are not allowed to travel backwards. Design an algorithm that calculates the number of ways (sequences of walks/leaps) that get you to the treasure stone. You should clearly explain the algorithm and demonstrate the correctness of the algorithm with a complete proof. Here is an example. For n = 1 5, there are 8 ways: Method 1: walk → walk → walk → walk → walk Method 2: walk → walk → walk → leap Method 3: walk → walk → leap → walk Method 4: walk → leap → walk → walk walk Method 5: leap → walk → walk → Method 6: leap → leap walk Method 7: leap → walk → leap Method 8: walk → leap leap
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer