Analyze each of the three algorithms in source code form. To analyze an algorith
ID: 663962 • Letter: A
Question
Analyze each of the three algorithms in source code form.
To analyze an algorithm, you will review the C++ source code, then give the upper bound (in "Big-Oh" notation) on the execution time of the algorithm and briefly explain your reasoning.
---------------------------------------------------------------------------------------------------------------------------------------------------------
algorithm 1-
---------------------------------------------------------------------------------------------------------------------------------------------------------
Good answer needed please
Explanation / Answer
1. it will be O(n2)
as there are two for loops in this code and each loop is running for n so n*n.
There is if condition which will run for n time only.
2. it will be O(n3)
as there are three for loops in this code and each loop is running for n so n*n*n.
There is if condition which will run for n time only.
3. it will be O(n)
as there are two for loops in this code and each loop is running for n so n.
There is if condition which will run for n time only.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.