; docx
Documents
User Generated
Resources
Learning Center
Your Federal Quarterly Tax Payments are due April 15th

# docx

VIEWS: 24 PAGES: 2

• pg 1
```									   Practical Session 2 – “Constants Don’t Matter!!!”

Algorithm Analysis

There exist c > 0 and n0 > 0 such that:
f(n) = O(g(n))
0 ≤ f(n) ≤ cg(n)   for each n ≥ n0

There exist c > 0 and n0 > 0 such that:
f(n) = Ω(g(n))
0 ≤ cg(n) ≤ f(n)   for each n ≥ n0

There exist c1, c2 > 0 and n0 > 0 such that:
f(n) = Θ(g(n))
0 ≤ c1g(n) ≤ f(n) ≤ c2g(n)   for each n ≥ n0

Some Basics
Prove: 100 * n + 12 = Θ(n).

Solution:

Prove:                           .

Solution:

Question 1
Prove :     (log n)log n = Ω(n3/2).

Question 2
Prove that log(n!) = Θ(n logn).
Question 3
Prove :      (log n)! = Ω (log(n!)).

Question 4
Give an example for two functions g(n) and f(n) such that neither g(n) = O(f(n)) nor
g(n) = Ω(f(n)).

Question 5
Prove: For any two functions f(n) and g(n), f(n) +g(n) = Θ(max(f(n),g(n))).

Question 6
Prove or disprove:

1. For any functions f(n) and g(n), f(n)=O(g(n))→g(n)= Ω (f(n)).

2. For any function f(n), f(n)=(f(n/2)) .

Question 7
Given a sorted array A of n distinct integers.

a) Describe an O(1) time algorithm that determines whether or not there exists an
element x, such that A[1] < x < A[n] and x is not in A.

b) Describe an O(logn) time algorithm that finds such an x.

c) Describe an efficient algorithm that determines whether or not there exists an
element i in A, such that A[i]=i. Analyze the running time of the algorithm.

Question 8

You have two jars made from a special secret material. You are in a tall building with
N floors, and you must determine what is the top floor M from which you can drop a
jar to the ground so that it doesn't break on impact. You can throw a jar out a window
as many times as you want as long as it doesn't break. Describe a strategy for finding the
highest safe rung that requires you to drop a jar at most f(n) times, for some function f(n) that
grows slower than linearly. (In other words, it should be the case that                    .

```
To top