Question: Question 4 only please, thank you so much! Exercise 1.9 Given 1n100 as the input parameter, two algorithms are available to calculate a function with
Question 4 only please, thank you so much!
Exercise 1.9 Given 1n100 as the input parameter, two algorithms are available to calculate a function with the following time and space complexity as shown in Table 1 . Table 1: Time and Space Complexity of Algorithms 1. Plot the time and space complexity function for algorithm A and B for 1n100. 2. Calculate the time and space complexity for n=10,20,30,50,70, and 100 for each algorithm. 3. If we define the total cost, C(n), of the algorithm as: C(n)=t(n)+5s(n). Now calculate the total cost for each of the two algorithms. Which one is the better algorithm? By how much? 4. Come up with a strategy that you would use to minimize the time and space complexity individually? (Hint: you can have a hybrid function where you can define which algorithm to use for a given n.) 5. Now calculate the total cost for the hybrid algorithm (assuming no overhead) that you have formulated in the previous question. How much better is the hybrid algorithm than algorithm A and B by itself
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
