Ask Question
19 June, 08:31

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

+5
Answers (1)
  1. 19 June, 09:50
    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 you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers