Question

Describe the order of magnitude of the following code section using Big(O) notation j = 1;...

Describe the order of magnitude of the following code section using Big(O) notation

j = 1;

While (j < N)

{

j = j * 2);

}

Can someone give me a more Clearer answer please.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For the given while loop the order of magnitude is
O(N)
because the loop iterates is based on N value..
which means the while loop executes N number of times..
The Big O notation is used for determined algorithm how it is responding to given input...
how fast if the input is small or big.
we use Big 0 Notation is verious like searching ,sorting etc..


lets take some algorithm which takes list and input to search in list
function(list,searchitem)
loop(from start to end)
searches for item
if founds returns true
or
else
goes till end and if not present it returns false

the complexity of above function is O(n)
O(N) is read as Order of N
O=> function is called function(order)
this is because we do approximations..called as order of magnitude.
Order of Magnitude is generally used for differentiang different classes of digits(numbers)


let us say difference between 1000 and 100000 is quite very large..if done as long as order of magnitude you will be close to it

in algorith O(N) to represent worst case..

suppose a list containing a 10000 elements and we want to search for 999th element..we can use different searching algorithms to find that element...and to anlaysis the bestcase,worstcase,average case different notations are there..o(n) it used for worst case complexity

Add a comment
Know the answer?
Add Answer to:
Describe the order of magnitude of the following code section using Big(O) notation j = 1;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT