Solved

Assertions
for Each of the Five Points Labeled by Comments

Question 2

Essay

Assertions
For each of the five points labeled by comments, identify each of the assertions in the table below as either being always true, never true, or sometimes true / sometimes false.
public static int randomWalk(int steps) {
Random rand = new Random();
int x = 0;
int r = rand.nextInt(2);
// Point A
while (steps > 0 || x == 0) {
// Point B
if (r == 0) {
x++;
// Point C
} else {
x = 0;
// Point D
}
steps--;
r = rand.nextInt(2);
}
// Point E
return x;
}
Fill in each box below with one of ALWAYS, NEVER or SOMETIMES. (You may abbreviate them as A, N, or S.)
 steps >0x>0r>0 Point A  Point B  Point C  Point D  Point E \begin{array}{l|c|c|c|} & \text { steps }>0 & \mathrm{x}>0 & \mathrm{r}>0 \\\hline \text { Point A } & & & \\\hline \text { Point B } & & & \\\hline \text { Point C } & & & \\\hline \text { Point D } & & & \\\hline \text { Point E } & & & \\\hline\end{array}

Correct Answer:

verifed

Verified

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents