Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Could anyone explain time-complexity on 4.2 and 4.3? asteI OI SIOwer Suppose that some algorithm A has running time f (n) and that algorithm B
Could anyone explain time-complexity on 4.2 and 4.3?
asteI OI SIOwer Suppose that some algorithm A has running time f (n) and that algorithm B has running time g(n), on all inputs of size n. Assume that f and g are functions N N+, and that limnoof(n) and limn009(n) are both infinity. Explain whether each statement in parts 2 and 3 below is true or false. Part 1 is already done for you 1. For some choice of g(n) with g(n) E S(f (n) log n): (a) A is faster than B on all sufficiently large inputs SOLUTION True. Choosing g(n) - f(n) ([log2 n] 1) satisfies the condition that g(n) 2(f (n) logn). For this choice, g(n) > f(n) for all n, and so B is slower than A on all inputs (b) A is slower than B on all sufficiently large inputs SOLUTION False. For all choices of g with g(n) e (f(n) logn), we have that g(n) > f(n) for sufficiently large n. So B is slower than A on all sufficiently large inputs This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. @0 For license purposes, the author is the University of British Columbia (c) A is faster than B on some inputs, and slower than B on other inputs SOLUTION True. Let nl 1 and f(na) > 1. Choose g(n-1 for n n2 . Then g(n) E (f(n) log n), g(n) > f(n) for all n > n2, and g(n)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