1. Engineering
  2. Computer Science
  3. find asymptotic time for the following functionint n int i...

Question: find asymptotic time for the following functionint n int i...

Question details

FIND ASYMPTOTIC TIME FOR THE FOLLOWING:

function(int n){

int i = 1;

while(i < n) {

int j = n;

while(j > 0) {

j = j/2;

}

i = 2*i;

}}

PLEASE INCLUDE ALL THE STEPS IN DETAIL AND EXPLAIN HOW YOU GOT THE ANSWER.

NOTE: I CALCULATED ANSWER TO BE O((log n)^2) ((with base 2)) but SOMEONE GOT ANSWER AS O(n^2). can u tell which one is correct and why?

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution