asked 154k views
4 votes
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]);

asked
User Morti
by
8.0k points

1 Answer

4 votes

Answer:

int j = 1; j < array.length; j =j *2

Step-by-step explanation:

j=j*2 loops have O(logn) so the running time of algorithm is O(logn).

answered
User Nicu Stiurca
by
9.2k points

No related questions found