2. (a) Derive a formula for the following that does not involve a summation: n i=1 (b) Let S be an unsorted array of n integers. Give an efficient algorithm that finds the pair x, y = S that minimizes |xy|. Justify the worst-case running time of your algorithm. 1 3. You are interested in analyzing some hard-to-obtain data from two separate databases. Each database contains n numerical values so there are 2n values total - and you may assume that no two values are the same. You'd like to determine the median of this set of 2n values, which we will define here to be the nth smallest value. However, the only way you can access thse values is through queries to the databases. In a single query, you can specify a value k to one of the two databases, and the chosen database will return the kth smallest value that it contains. Since queries are expensive, you would like to compute the median using as few queries as possible. Give an algorithm that finds the median value using at most O(log n) queries. 4. (a) Fill in the '?' to make the following statement true. n T(n) = 1.01¯ = (?). i=1 (b) Use a recursion tree to compute an asymptotic solution for the recurrence G(n) G(2n/3) + G(n/3) + n. 5. Give asymptotic bounds for T(n) in each of the following recurrences. Assume any reasonable base cases in the recurrences below, for example, T(n) is constant for n < 2. Make your bounds as tight as possible, and justify your answers. (a) T(n) = 9T(n/3)+225n = (b) T(n) T(9n/10) + logn (c) T(n) 3T(n/2) + n² √n (d) T(n) T(n-1)+n2

icon
Related questions
Question

Solve numbers 2 - 5 and show work for the attached image

 

2. (a) Derive a formula for the following that does not involve a summation:
n
i=1
(b) Let S be an unsorted array of n integers. Give an efficient algorithm that finds the pair
x, y = S that minimizes |xy|. Justify the worst-case running time of your algorithm.
1
3. You are interested in analyzing some hard-to-obtain data from two separate databases. Each
database contains n numerical values so there are 2n values total - and you may assume
that no two values are the same. You'd like to determine the median of this set of 2n values,
which we will define here to be the nth smallest value.
However, the only way you can access thse values is through queries to the databases. In a
single query, you can specify a value k to one of the two databases, and the chosen database
will return the kth smallest value that it contains. Since queries are expensive, you would
like to compute the median using as few queries as possible.
Give an algorithm that finds the median value using at most O(log n) queries.
4. (a) Fill in the '?' to make the following statement true.
n
T(n) = 1.01¯ = (?).
i=1
(b) Use a recursion tree to compute an asymptotic solution for the recurrence
G(n) G(2n/3) + G(n/3) + n.
5. Give asymptotic bounds for T(n) in each of the following recurrences. Assume any reasonable
base cases in the recurrences below, for example, T(n) is constant for n < 2. Make your
bounds as tight as possible, and justify your answers.
(a) T(n)
=
9T(n/3)+225n
=
(b) T(n) T(9n/10) + logn
(c) T(n)
3T(n/2) + n² √n
(d) T(n)
T(n-1)+n2
Transcribed Image Text:2. (a) Derive a formula for the following that does not involve a summation: n i=1 (b) Let S be an unsorted array of n integers. Give an efficient algorithm that finds the pair x, y = S that minimizes |xy|. Justify the worst-case running time of your algorithm. 1 3. You are interested in analyzing some hard-to-obtain data from two separate databases. Each database contains n numerical values so there are 2n values total - and you may assume that no two values are the same. You'd like to determine the median of this set of 2n values, which we will define here to be the nth smallest value. However, the only way you can access thse values is through queries to the databases. In a single query, you can specify a value k to one of the two databases, and the chosen database will return the kth smallest value that it contains. Since queries are expensive, you would like to compute the median using as few queries as possible. Give an algorithm that finds the median value using at most O(log n) queries. 4. (a) Fill in the '?' to make the following statement true. n T(n) = 1.01¯ = (?). i=1 (b) Use a recursion tree to compute an asymptotic solution for the recurrence G(n) G(2n/3) + G(n/3) + n. 5. Give asymptotic bounds for T(n) in each of the following recurrences. Assume any reasonable base cases in the recurrences below, for example, T(n) is constant for n < 2. Make your bounds as tight as possible, and justify your answers. (a) T(n) = 9T(n/3)+225n = (b) T(n) T(9n/10) + logn (c) T(n) 3T(n/2) + n² √n (d) T(n) T(n-1)+n2
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer