Ask Question
2 April, 04:17

Give a big-o estimate for the number additions used in this segment of an algorithmi:=0, for i:=1 to n, for j: = 1 to n, t:=t+i+j

+2
Answers (1)
  1. 2 April, 04:18
    0
    We have a "square" double loop, meaning that both loops go to completion at n.

    So there are n^2 executions of t:=t+i+j.

    Assuming two additions per execution of the innermost loop, (i. e. ignoring the implied additions in increment of subscripts), we have 2n^2 additions in all.

    Therefore the given code section is of O (n^2), i. e. the highest power (if polynomial) and ignore coefficients.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Give a big-o estimate for the number additions used in this segment of an algorithmi:=0, for i:=1 to n, for j: = 1 to n, t:=t+i+j ...” in 📗 Mathematics if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers