Running time function

49 Views Asked by At

I'm trying to learn and understand how to find big O notation .

well, here I need to find big-O notation for these algorithms , and I did the calculating for the running time for these algorithms but I'm not sure if my attempt is correct or not.

1)

    x←1      → 1
for i←1 to n    
     j←1        
     while j<n     
           x← max(x, i*j)     
           j← 2*j         
return x      → 1

2)

x←1         → 1
for i←1 to n    
    x←max(x,i)        
for j← 1 to n2       
    x←max(x,j)       
return x                →1