Chapter 3 Flashcards

1
Q

Show that for any real constants a and b, where b > 0,

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is 2^{n + 1} = O(2^n)2n+1=O(2n)? Is 2^{2n} = O(2^n)22n=O(2n)?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Prove that the running time of an algorithm is Θ(g(n)) if and only if its worst-case running time is O(g(n)) and its best-case running time is Ω(g(n)).

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Rank the following functions by order of growth; that is, find an arrangement 𝑔1, 𝑔2, … , 𝑔12 of the functions satisfying 𝑔1 = Ξ©(𝑔2 ), 𝑔2 = Ξ©(𝑔3 ), … , 𝑔11 = Ξ©(𝑔12). Partition your list into equivalence classes such that functions 𝑓(𝑛) and 𝑔(𝑛) are in the same class if and only if 𝑓(𝑛) = Θ(𝑔(𝑛)).

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Prove:

  • 𝑛! = π‘œ(𝑛^𝑛).
  • 𝑛! = Ο‰(2 𝑛).
  • lg(𝑛 !) = Θ(𝑛 lg 𝑛).
A

Answer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

.

A

f. Prove, from the first, we know that 0≀ f(n) ≀ cg(n) and we need to prove that 0 ≀ df(n )≀ g(n), which is straightforward with d=1/c.
g. Disprove, let’s pick f(n) = 2^nf(n)=2n. We will need to prove that

βˆƒc1​,c2​,n0 ​: βˆ€ n β‰₯ n0​, 0 ≀ c1 ​⋅ 2^n/2 ≀ 2n ≀ c2 ​⋅ 2^n/2,

which is obviously untrue.

h. Prove, let g(n) = o(f(n)). Then

βˆƒc,n0 ​: βˆ€ nβ‰₯n0​ , 0 ≀ g(n) < cf(n).

We need to prove that

βˆƒc1​,c2​,n0 ​: βˆ€ n β‰₯ n0​ , 0 ≀ c1​f(n) ≀ f(n) + g(n) ≀ c2​f(n).

Thus, if we pickc1​=1 and c2​=c+1, it holds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Write a recursive algorithm to implement the Tower of Hanoi game. The Tower of Hanoi is a very famous game. In this game, there are three pegs and N number of disks placed one over the other in decreasing size. The objective of this game is to move the disks one by one from the first peg to the last peg. And there is only one condition, we cannot place a bigger disk on top of a smaller disk. What is the time complexity of your algorithm?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly