2. Super Mario must travel through a landscape made up of n spaces each filled with a mushroom, a spike or nothing. He...
2. Super Mario must travel through a landscape made up of n spaces each filled with a mushroom, a spike or nothing. He wishes to reach the princess who is on space n. Super Mario can choose to advance 1 step or jump J steps. To start, J- 2, if he lands on a space that has a mushroom then J increases by You are given an array of the landscape L1,.., n] such that L] N if there is nothing on space i, LM if there is a mushroom on space i and LliS if there is a spike on space i. Design an algorithm that returns the minimum number of actions needed (jump or advance) for Super Mario to reach space n without hitting a spike.
2. Super Mario must travel through a landscape made up of n spaces each filled with a mushroom, a spike or nothing. He wishes to reach the princess who is on space n. Super Mario can choose to advance 1 step or jump J steps. To start, J- 2, if he lands on a space that has a mushroom then J increases by You are given an array of the landscape L1,.., n] such that L] N if there is nothing on space i, LM if there is a mushroom on space i and LliS if there is a spike on space i. Design an algorithm that returns the minimum number of actions needed (jump or advance) for Super Mario to reach space n without hitting a spike.