# Assignment Part A

Content type
User Generated
Subject
Java
Type
Homework
Rating
Showing Page:
1/1
Assignment A
Worst case runtime of line 7?
O(n)
since it takes (n ) operations to check for the condition
Best case runtime of line 7?
O(1) since it takes one operation to check for the condition
What is the worst case runtime of the loop between line 9 and 15?
O(n+5)
Explanations
It takes n time for for loop initialization plus 1 time for statements in the for loop.
That is (1*5)+n
Thus runtime = O(n+5)
Best case running time of the loop between line 9 and 15
O(n)
For best case it take only (n) time for loop initialization to return the condition.
What is the worst case runtime of the entire mystery method?
O(n^2)
Exp;
The time complexity for the inner loop is O(n)
Time complexity of outer loop is O(n)
Hence running time of the whole method is O(n*n)= O(n^2)

Unformatted Attachment Preview
Assignment A Worst case runtime of line 7? O(n) since it takes (n ) operations to check for the condition Best case runtime of line 7? O(1) since it takes one operation to check for the condition What is the worst case runtime of the loop between line 9 and 15? O(n+5) Explanations It takes n time fo ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
Nice! Really impressed with the quality.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4