Question
Consider the algorithm DoSomething below a) What is the big-O (O(n)) and big-Omega ((n)) time complexity for algorithm DoSomething in terms of n? Show all
Consider the algorithm DoSomething below
a) What is the big-O (O(n)) and big-Omega ((n)) time complexity for algorithm DoSomething in terms of n? Show all necessary steps. b) Trace (hand-run) DoSomething for an array A = (71,15,45,98,04,32). What is the resulting M? c) What does DoSomething do? Explain that clearly and briefly given any arbitrary array A of n integers? d) Can the runtime of DoSomething be improved easily? Explain how (i.e. re-write another solution(s) that does exactly what DoSomething is doing more efficiently)? e) Can the space complexity of DoSomething be improved? Explain how?
Algorithm DoSomething (A, n) Input: Array A of integer containing n elements Output: Array M of integer containing n elements 1. for i-0 to n-1 do 2. Zomli]-0 3. end for 4. for i-0 to n-2 do 5. forj-it1 ton-1 do 6. ifAliJKAi] then 7. 8. else .end if 11. end for 12. end for 13. for i-0 to n-1 do 14. MZom [i]]=A[i] 15. end for 16. Return M 10
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started