Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Multiplication by a constant: f ( n ) i n O ( g ( n ) ) = > f ( n ) i n

Multiplication by a constant:
f(n)inO(g(n))=>f(n)inO(g(n)),c>0
Addition:
a(n)inO(f(n))&b(n)in(g(n))=>a(n)+b(n)in(f(n)+g(n))
Multiplication:
a(n)in(f(n))&b(n)in(g(n))Longrightarrowa(n)b(n)inO(f(n)g(n))
Transitivity:
a(n)inO(f(n))&f(n)inO(g(n))Longrightarrowa(n)inO(g(n))
Polynomials:
f(n) is a polynomial of degree
Exponential bound on polynomial:
nxinO(an) for any fixed x>0,a>1
E.g.,n1000inO(2n)
Log of power:
lognxinO(logn) for any fixed x>0
Because: lognx=xlogninO(logn)
Power of log:
logxn=(logn)xinO(ny) for any fixed x>0,y>0
Let f(n)=(n+3)(n2+1)
(a) Find g(n) such that f(n) is O(g(n)).
(b) What are c and n0 that shows your answer is correct?
If f(n)=n1000+3n2 and g(n)=2n, is f(n)ino(g(n))? Why or why not?
Suppose f(n)=(log6n)(logn3). Show that f(n) is O(nlogn).
Suppose we have the following algorithm:
Algorithm Cartesian (A,B,n)
Input: A and B, two n-element lists
Output: The Cartesian product of the two lists: [[A[0],B[0]],[A[0],B[1]],dots]
Let C be an empty list
for i from 0 to n-1 do
for j from 0 to n-1 do
Add [A[i],B[j]] to the end of C
return C
End.
(a) What is the time complexity using the RAM mdel (i.e., directly counting operations)? Make sure you explain your answer in terms of the operations you consider primitive.
(b) Is this algorithm's running time O(n3)? Wh or why not?
(c) Is this algorithm's running time (n2)? Why or why not?
(d) Is this algorithm's running time (n)? Why or why not?
Suppose that we add a loop between lines ?? and ?? of the algorithm in question ?? that prints the list, one element at a time. Which of the answers you gave in question ?? would be different now? Why?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions