Proving f(n) = O(log n) with Induction

  • Thread starter EvLer
  • Start date
  • Tags
    Induction
In summary, the conversation discusses the method for showing that the function f(n) = f(n-1) + 1/n is O(logn). The use of induction is suggested and it is noted that the harmonic series grows at a certain rate. Comparing the growth of the harmonic series to the graph of logn, it is concluded that logn is the upper bound.
  • #1
EvLer
458
0
How can I show that function defined as

f(n) = f(n-1) + 1/n is O(logn) ?

Do I need to use induction here?

Thanks in advance.
 
Physics news on Phys.org
  • #2
Note that, by induction, you have:
[tex]f(n)=a_{0}+\sum_{i=1}^{n}\frac{1}{i}[/tex]
where [tex]a_{0}[/tex] is some constant.
Now, you need to find "how fast" the harmonic series grows..
 
Last edited:
  • #3
Thanks for reply.
Would it be right to describe it as:
for n0 > 2, c = 1, then f(n) < c * g(n) ?
Looking at the graphs, or rather how the harmonic series behaves compared to the graph of logn, it is kind of obvious that logn is the upper bound.
Thanks again.
 

1. How do you prove that f(n) = O(log n) using induction?

Firstly, we assume that f(n) = O(log n) is true for some constant k. Then, we use induction to prove that f(n+1) = O(log(n+1)) by showing that the inequality f(n+1) ≤ k * log(n+1) holds true for all n ≥ 1. This can be done by rewriting f(n+1) in terms of f(n) and using the induction hypothesis.

2. What is the intuition behind using induction to prove f(n) = O(log n)?

The intuition behind using induction is that we can break down the proof into smaller steps, starting with the base case (n=1) and then showing that if the statement holds for n, it also holds for n+1. This allows us to build up the proof for all values of n, and ultimately prove that f(n) = O(log n) for all n ≥ 1.

3. Can you provide an example of using induction to prove f(n) = O(log n)?

Sure, let's say we have the function f(n) = n^2 + log n. We want to prove that f(n) = O(log n) using induction. Firstly, we assume that f(n) = O(log n) is true for some constant k. Then, we show that f(n+1) ≤ k * log(n+1) by rewriting f(n+1) as (n+1)^2 + log(n+1) and using the induction hypothesis for f(n). This will prove that f(n) = O(log n) for all n ≥ 1.

4. Is induction the only method for proving f(n) = O(log n)?

No, there are other methods such as direct proof, proof by contradiction, and proof by contrapositive. However, induction is a commonly used method for proving statements about recursive functions, and it can be particularly helpful for proving f(n) = O(log n).

5. Can induction be used to prove f(n) = O(log n) for non-recursive functions?

Yes, induction can be used to prove f(n) = O(log n) for non-recursive functions as long as the function can be broken down into smaller steps that can be proven using induction. For example, if we have a function that involves a summation, we can use induction to prove that the summation is bounded by a logarithmic function.

Similar threads

  • Introductory Physics Homework Help
Replies
10
Views
527
  • Introductory Physics Homework Help
Replies
25
Views
1K
  • Introductory Physics Homework Help
3
Replies
95
Views
4K
  • Programming and Computer Science
Replies
9
Views
304
  • Introductory Physics Homework Help
Replies
8
Views
269
  • Introductory Physics Homework Help
Replies
1
Views
258
  • Introductory Physics Homework Help
Replies
13
Views
939
  • Introductory Physics Homework Help
Replies
5
Views
456
  • Calculus and Beyond Homework Help
Replies
1
Views
495
  • Introductory Physics Homework Help
Replies
3
Views
193
Back
Top