Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (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).

OpenStudy (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.

OpenStudy (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).

OpenStudy (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 =)

OpenStudy (anonymous):

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

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Breathless: Spooky witch but cute
6 hours ago 3 Replies 0 Medals
Arriyanalol: help
6 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 4 Medals
Jaded012023: Please tell me what you all think of this song
9 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
9 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!