# How do you calculate the running time using Big-O notatation? I’m still new to Data Structure and Algorithm and therefore I would like to ease my doubts. I’m required to find the Big-O running time of myMethod():

`` Static int doIt(int n) {            for 𝑖←1 𝑡𝑜 100 do    -> 100              for 𝑘←1 𝑡𝑜 𝑛 do    -> n x 100                  𝑗←1;𝑚←𝑛       -> 1            while 𝑗<𝑚 do       -> lg n           𝑚←(𝑚+𝑗)/2           -> lg n/2         end while          end for          end for          }   static int myMethod(int n) {                   𝑖 ←1                   𝑤ℎ𝑖𝑙𝑒 (𝑖 < 𝑛) {          -> lg n                         𝑑𝑜𝐼𝑡(𝑛)            -> ?                          𝑖←𝑖×2             -> lg n         }             𝑟𝑒𝑡𝑢𝑟𝑛 1;   } ``

For each of the line I have inserted the answer I think would be a logical value to put e.g "-> 100". However I am not confident with the answer. These are the following questions that I would like to ask as well:

1. Does all while loop have a value of lg n?

2. If the doIt(n) method does not have a return statement, do we still add in part of calculation?

3. For the line with m <- (m+j)/2, the value I have inputted is lg n /2. Is that correct or is it some other value?

4. Whenever multiplying by 2 or dividing by 2 is it always lg 2? what if n is multiplied by 3?

Thank You Posted on Categories proxies