Академический Документы
Профессиональный Документы
Культура Документы
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)
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
(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)
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