please help me :)
Consider the program segment below. Assume k is a positive number.

for (int i = 2; i <= k; i++)
if (nums[i] < someValue)
System.out.println("FOUND");
What is the maximum number of times FOUND can be printed?

Group of answer choices

k - 1

1

0

k

k - 2

Respuesta :

Answer:

k - 1 times

Explanation:

Given

The attached code snipped

Required

Maximum number of times, the print statement is executed

From the iteration, we have: i = 2; i<=k; i++

This means that; i = 2 to k

Say: [tex]k = 5[/tex]

[tex]i = 2, 3,4,5[/tex] (4 values) i.e. 5 - 1

Say [tex]k = 10[/tex]

[tex]i = 2,3,4,5,6,7,8,9,10[/tex] (9 values) i.e. 10 - 1

So, the maximum number of times is k - 1