Big O Algorithm What (A, n) A left arrow new 2-dimensional array of n x n intege
ID: 3564483 • Letter: B
Question
Big O
Algorithm What (A, n) A left arrow new 2-dimensional array of n x n integers s left arrow 0 for i left arrow 2 to n-1 do for j left arrow i-1 to i+1 do s left arrow s + A[i][j] end for end for Answer the following questions: 2.a [3 pts] What is the Big-O order of the memory required by the algorithm? Answer: 2.b [3 pts] What is the Big-O order of the operations required by the algorithm? Answer: 2.c [3 pts] How many times is the statement in the innermost loop executed, as a function of n? Answer: 2.d [3 pts] What are the best and worst case scenarios of order of operations of this algorithm? Answer:Explanation / Answer
Q2 a::::
Answer :::: O(n^2) memory required due to make new 2d memory
Q2 b::::
Answer :::: O(n^2) //nested loop used
Q2 c::::
Answer :::: O(1) //statement
Q2 d::::
Answer :::: worst case O(n^2) and best case O(nlogn)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.