Question: You are given this algorithm for input of size n , with the lines numbered: 1 : result = 0 2 : i = 1
You are given this algorithm for input of size n with the lines numbered:
: result
: i
: while i n:
: j
: while j n:
: result result j
: j j
: i i
: return result
a Using bigO how many times will line of this algorithm be executed? Justify your answer.
b Using bigO how many times will line of this algorithm be executed? Justify your answer.
c Using bigO what is the time complexity of this algorithm? Justify your answer.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
