679 views
0 votes
0 votes

Consider the following 


function(n)
{ 
    val=0;
    
    for i=1 to n
    {
       if(n<=10000)
          
            for j=1 to n

                for k=1 to n
                   
                     val = val + 1;
      
        else
          
            for j=1 to n
     
                val = val + 1;
     }

}

 

The running time of the above function can best be described by $T(n)=$____________

$A)\theta(n^{3}) $                         $B)\theta(n^{2})$                      $C)\theta(n)$                                 $D)\theta(1)$

1 Answer

0 votes
0 votes
Its running time will be 0(n^3)+0(n^2) =0(n^3) will be time complexity

Related questions

0 votes
0 votes
1 answer
1
1 votes
1 votes
3 answers
2
Manu Thakur asked Aug 29, 2017
2,803 views
The innermost loop will execute when j is multiple of i, and that will happen exactly i times. Please help me to find the time complexity of the below program:
0 votes
0 votes
1 answer
3
1 votes
1 votes
2 answers
4
Siramdas Vamshidhar asked Dec 9, 2014
379 views
for(i=1;i<=n;i++) for(j=n/3;j<=2n;j+=n/3) x=x+1;