Question: Consider the following function: int loop ( int N ) { / / Precondition: { N > = 0 } Random rand = new Random
Consider the following function:
int loopint N
Precondition: N
Random rand new Random;
forint i ; i N ; i
ifi
System.out.printlnBegin iteration";
forint j ; j Math.pow Math.pow i; j
System.out.printType: ; S
int cond rand.nextInt;
ifcond
System.out.printlnThing;
else ifcond
System.out.printlnSomething;
else
System.out.printlnNothing;
Q
How many times will the line commented as S be run? Write your answer as a closedform expression in terms of N Show your work.
Q
How many feasible paths do you have in this program? Again the answer should be expressed as a closedform expression in terms of N
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
