Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5 1 0 4 2 3 0 1 2 3 4 5 a 1 . a is a list of 'int' 2 . Length of
a
a is a list of 'int'
Length of list a is NOT known. YOU CANNOT CALL lena
If the length of the list is as shown above
the content of the array is guaranteed to be between to
THERE IS NO REPETATION of numbers
a ;
int h hopa;
Your task is to find the number of hops to get which is defined as follows:
The top level call is as follows:
a
a
a
a
a
h Number of hop is
You start from ax in this case x a and keep looping
until you get x which is The number of times you hoped, in this example, is h
One way, to write, using while loop is:
Now write "hop" subroutine as follows:
You cannot change interface of hop function
You cannot use globalstatic variables
You cannot use any loop statements
like while, do for and goto
You cannot call any function except hop
Your code should not be more than lines
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started