anonymous
  • anonymous
Give big-O estimate for the number of operations (multiplication or addition) used in the following algorithm segment (ignore comparisons to check while conditions).
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
i =1 t = 0 while i <= n i = t+i t = 2i I don't understand how it grows (other than rather ripidly), let alone how quickly it approaches n.
anonymous
  • anonymous
Generally BIG'O notation is asymptotic analysis so it considers only average case.... so for above case 4,5 line both assignments are considered as one operation and since we are iterating n times the complexity is O(n).
anonymous
  • anonymous
I'm pretty sure the big O is actually O(log n) Not really a proof but anyway. If you write out the values before each iteration of the loop you get. L - iteration number L i t 1 1 0 2 1 2 3 3 6 4 9 18 5 27 54 6 81 162 So if n was 80 it would take 6 iterations You can see i is growing like 3^(L-2) So if n was 1000 1000 = 3^(L-2) log(1000) [base 3] = L - 2 log(1000) [base 3] + 2 = L 8.287709822868152 = L and if you ceil the answer you get L = 9 and just to check with the table 6 81 162 7 243 486 8 729 1458 9 2187 ... The table isn't perfect but hopefully you get the main idea. Hope this helps =)

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
@ndan ... your right ,Im sorry i didnt see the relation between i and t ... thanks for the correction

Looking for something else?

Not the answer you are looking for? Search for more explanations.