Вы находитесь на странице: 1из 3

15021J0019

Problem Set A
1. Determine the big-O notation for the following

5n^(5/2) + n^(2/5)
Answer: O(n^5/2)

6 log(n) + 9(n)
Answer: O(n)

3n^4 + n log(n)
Answer: O(n^4)

5n^2 + n^(3/2)
Answer: O(n^2)

2. Determine whether each of these function is O(x).

f(x) = 10
Ans: yes, it is a constant..

f(x) = 3x + 7
Ans: yes, it has constant x term

f(x) = x^2 + x + 1
Ans: No, it is polynomial.

f(x) = 5 log(x)
Ans: yes, it executes into constant

f(x) = ciel(x)
Ans: yes it executes into constant

f(x) = floor(x)
Ans: yes it executes into constant

3. Use the definition of "f(x) is O(g(x))" to show that x^2 + 17 is O(x^4).


(x^2 + 17)<x^4+x^2+17
(X^2+17)^2< x^4+x^2+17
X^4+34x^2+289< x^4+x^2+17
theO(x^4).
4. Show that (x^3 + 2x)/(2x + 1) is O(x^2)
(x^3 + 2x)/(2x + 1)
Divide with x numerator and denominator
(x^3 + 2x)/x/(2x + 1)/x<=O(x^2)6
X^2+2/2+1/x<=)O(x^2)
O(x^2)
5. Give as good a big-O estimate as possible for each of these functions.

(n^2 + 8)(n+1)
(n^3+8n+n^2+8)
n^3+n^2+8n+8
big O(n^3)

(n log(n) + n^2)(N^3 + 2)
(nlog(n)N^3)+n^2(N^3)+2nlog(n)+2n^2
Log(n)^4+n^5+2nlog(n)+2n^2
Big O(n^5)

(n! + 2^n)(n^3 + log(n^2 + 1))


n!n^3+n!log(n^2+1)+2^n*n^3+2^n*log(n^2+1)
n!n^3+n!log(n^2+1)+2n^3n+2log(n^2+1)^2
O(n!log(n^2+1))

Problem Set B
1. What is the complexity of the below problem
Given a set of p points, find the pair closest to each other.
Closet point (( x2-x1)^2+(y2-y1)^2)^1/2
(X2-x1)+(y2-y1)----------------------------------------------------------O(x)
2. Determine the least number of comparisons or best case performance.
1. used to locate an element in a list of n terms with a linear search
best case is 1
worst case is O(n)
2. used to locate an element in a list of n terms using a binary search.
Best case: n/2
Worst case: log n

Вам также может понравиться