Solved

The Code Segment Below Prints Some of the Elements in an Array

Question 35

Multiple Choice

The code segment below prints some of the elements in an array with size n. Select an expression to complete the code segment so that the resulting algorithm has O(log n) running time. for __________________________
{
System.out.println(array[j]) ;
}


A) (int j = 0; j < array.length; j = j + 2)
B) (int j = 1; j < array.length; j = j * 2)
C) (int j = 0; j < array.length / 2; j++)
D) (int j = 0; j < array.length; j++)

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions