Algorithms A and B perform the same task. On input of size n, algorithm A executes 0.003n2 instructions, and algorithm B executes 243n instructions. Find the approximate value of n above which algorithm B is more efficient. (You may use a calculator or spreadsheet.)
We simply wish to find the point where algorithm A and B have equal execution times;
B will be more efficient above this point.
Therefore, we simply wish to solve the equation:0.003n2= 243n . We can simplify this to n= 243 / .003, or n= 81000. .Therefore B will be the more efficient algorithm on input with size greater than 81000
Algorithms A and B perform the same task. On input of size n, algorithm A executes...
Problem 2. (5 pts.) Algorithms A and B perform the same task. On input of size n, algorithm A executes 10 n 2 steps, and algorithm B executes 100,000 steps. Find the value of n above which algorithm B is more efficient. Show your work.
An algorithm A executes some instructions to solve a problem of size n, the total number of instruction is Θ (n3). An algorithm B executes half the instructions of A to solve the same problem of size n. What is the Big Theta of B (justify your answer) ?
Consider four algorithms for doing the same task with exact running times of n log2 n, n 2 , n 3 , and 2n (the algorithms take n log2 n, n 2 , n 3 , and 2n operations to solve the problem), respectively, and a computer that can perform 10^10 operations per second. Determine the largest input size n that can be processed on the computer by each algorithm in one hour.
Q4) [5 points] Consider the following two algorithms: ALGORITHM 1 Bin Rec(n) //Input: A positive decimal integer n llOutput: The number of binary digits in "'s binary representation if n1 return 1 else return BinRec(ln/2)) +1 ALGORITHM 2 Binary(n) tive decimal integer nt io 's binary representation //Output: The number of binary digits in i's binary representation count ←1 while n >1 do count ← count + 1 return count a. Analyze the two algorithms and find the efficiency for...
A certain computer algorithm executes three times as many operations when it is run with an input of size n as when it is run with an input of size n -1 (where n > 1 is an integer). When the algorithm is run with an input of size 1, it executes ten operations. Let sn be the number of operations the algorithm executes when it is run on an input of size n. Find a closed form for s....
11. (12 marks 4x 3 marks) Consider four algorithms for doing the same task with exact running times of n log2 n, n', », and 2n, respectively, and a computer that can perform 1010 operations per second. Determine the largest input size n that can be processed on the computer by each algorithm in one hour
Your task is to design algorithms to solve the following problems. For full credit, your algorithm must run in logarithmic time. Given a number n greaterthanorequalto 1 and a (user-specified) error tolerance e, you want to approximate the squareroot of n to within error tolerance e. Specifically, you want to return an x = Squareroot n that satisfies |x^2 - n| greaterthanorequalto e. For example, to compute the squareroot of n = 2 with e = 0.01, an acceptable answer...
In python Programming Exercise 1 Write a function that will have a list as an input, the task of the function is to check if all the elements in the list are unique,( i.e. no repetition of any value has occurred in the list), then the function returns true otherwise it returns false. Your program should include a main method that call the method to test it. Algorithm Analysis For the function you implemented in part 1, please calculate T(n),...
1) Let A and B be two programs that perform the same task. Let tA (n) and tB (n), respectively, denote their run times. For each of the following pairs, find the range of n values for which program A is faster than program B. Show the values for each and how you obtained them (justify). a) tA (n) =1000n , tB (n) =10n^2 b) tA (n) = 2n^2 , tB (n) = n ^3 c) tA (n) = 2^n...
** Use Java programming language Program the following algorithms in JAVA: A. Classical matrix multiplication B. Divide-and-conquer matrix multiplication In order to obtain more accurate results, the algorithms should be tested with the same matrices of different sizes many times. The total time spent is then divided by the number of times the algorithm is performed to obtain the time taken to solve the given instance. For example, you randomly generate 1000 sets of input data for size_of_n=16. For each...