Answer:
Solution : Using Master's theorm
Here a = 8 b = 2 , f(n) = 100n^2 , c = 2
loga base b = log 8 base 2 = 3 , c < log a base b , therefore T1(n) = theta(n^c) = theta(n^2)
Therefore T1(n) = theta(n^2)
Using Masters Theorm
Here a = 63 , b = 4 , c = 2 , f(n) = 200n^2
Now loa a base b = loag 63 base 4 = 4
Here c < log a base b , therefore T2(n) = theta(n^2)
Suppose we have two algorithms A1 and A2 for solving the same problem. Let T_1(n) be...
Suppose that we have two algorithms A1 and A2 for solving the same problem. Let T1(n) be the worst-case time complexity of A1 and T2(n) be the worst-case time complexity of A2. We know that: T(1)=1 T1(n)=15*T1(n/2)+n^2, n>1 T2(1)=1 T2(n)=80*T2(n/3)+20n^3,n>1 a. Use the master method to decide T1(n) b. Use the master method to decide T2(n) c. Which algorithms is more efficient? Why?
1. Suppose you are given 3 algorithms A1, A2 and A3 solving the same problem. You know that in the worst case the running times are Ti(n) = 101#nº + n, Ta(n) = 10”, TS(n) = 101 nº logo n10 (a) Which algorithm is the fastest for very large inputs? Which algorithm is the slowest for very large inputs? (Justify your answer.) (b) For which problem sizes is Al the best algorithm to use (out of the three)? Answer the...
Given the following algorithm:
Algorithnm Input: a1, a2,...,an, a sequence of numbers n, the length of the sequence x, a number Output: ?? i:- 1 While (x2 # a, and i < n) i+1 End-while If (x- - a) Return(i) Return(-1) 3, -1, 2,9, 36,-7, 6,4 a) What is the correct output of the Algorithm with the following input: a1, a2,..an b) What is the asymptotic worst-case time complexity of the Algorithm?
Algorithnm Input: a1, a2,...,an, a sequence of numbers...
Analysis of Algorithms Fall 2013 Do any (4) out of the following (5) problems 1. Assume n-3t is a power of 3 fork20. Solve accurately the following recursion. If you cannot find the exact solution, use the big-O notation. Tu) T(n)Tin/3)+2 2. Suppose that you have 2 differeut algorithms to solve a giveu probleen Algorithm A has worst-case time complexity e(n2) and Algorithm B has worst-case time complexity e(nlog n). Which of the following statements are true and which are...
Suppose that we are given a sorted array of distinct integers A[1, ......, n] and we want to decide whether there is an index i for which A[i] = i. Describe an efficient divide-and-conquer algorithm that solves this problem and explain the time complexity. 1. Describe the steps of your algorithm in plain English. 2. Write a recurrence equation for the runtime complexity. 3. Solve the equation by the master theorem.
algorithms
Assume you have the choice of two algorithms for the same problem, (a) One that reduces a problem of size n in O(n) time to two sub-problems of size in, or (b ) One that solves the problem without any recursion in time O(n2) Which algorithm is faster? Show that if f(n) f(½n) + O(log(n)), then f(n) = O((log n) 4. Write code for a function that takes a nonempty search tree of the form discussed in the class,...
please I need it urgent thanks algorithms
2.1 Searching and Sorting- 5 points each 3. What is the worst case for quick sort? What is the worst case time com- plexity for quick sort and why? Explain what modifications we can make to quick sort to make it run faster, and why this helps. 4. Give pseudocode for an algorithm that will solve the following problem. Given an array AlL..n) that contains every number between 1 and n +1 in...
problem 2
can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to write its pseudo-code). To sort an array A, you will then call Det-QuickSort(A, 1, n). You also need to provide the worst case time complexity analysis of your algorithm. 2. (20 points) Given a set of n distinct numbers, we wish to find the k largest in sorted order using a comparison-based algorithm. Give an algorithm that implements each of the following methods, and...
Suppose you are given an array of n integers a1, a2, ..., an. You need to find out the length of its longest sub-array (not necessarily contiguous) such that all elements in the sub-array are sorted in non-decreasing order. For example, the length of longest sub-array for {5, 10, 9, 13, 12, 25, 19, 70} is 6 and one such sub-array is {5, 10, 13, 19, 70}. Note you may have multiple solutions for this case. Use dynamic programming to...
2. Consider a circular array based Queue as we have discussed in the lectures (class definition given below for reference) public class CircArrayQueue<E> implements Queue<E private EI Q private int front-0 indicates front of queue l indicates position after end of queue private int end-0: public CircArrayQueue( public int getSize (.. public boolean isEmpty ( public void enqueue (E e)... public E dequeue ) throws EmptyQueueException... Il constructor We are interested in implementing a Stack class based on the above...