Determine Big O of a function (Discrete math)

In summary, you have shown that log(n2+1) is O(logn) by demonstrating that there exists constants C and k such that log(n2+1)≤Clog(n) whenever n>k. This means that the function grows at the same rate as log(n) and can be considered "big O" of log(n).
  • #1
Miike012
1,009
0
Question:
Determine whether the function log(n2+1) is O(logn).

Definition in paint document if needed.

Solution:

n2 + 1 < 2n2 whenever n>1

log(n2 + 1) < log( 2n2 ) = log(2) + 2log(n).

Now, log(n)>log(2) whenever n>2. Therefore

log(2) + 2log(n)<3log(n).

log(n2 + 1) ≤ 3log(n) whenever n>2.
∴Because there exists constants C and k such that log(n2 + 1)≤Clog(n) whenever n>k we can conclude log(n2 + 1) is O(logn).


Is this correct? The book says that log(n2 + 1) is not O(logn).
 

Attachments

  • DD.jpg
    DD.jpg
    8.1 KB · Views: 954
Physics news on Phys.org
  • #2
I think the book is wrong and you are right.
 
  • #3
Miike012 said:
Question:
Determine whether the function log(n2+1) is O(logn).

Definition in paint document if needed.

Solution:

n2 + 1 < 2n2 whenever n>1

log(n2 + 1) < log( 2n2 ) = log(2) + 2log(n).

Now, log(n)>log(2) whenever n>2. Therefore

log(2) + 2log(n)<3log(n).

log(n2 + 1) ≤ 3log(n) whenever n>2.
∴Because there exists constants C and k such that log(n2 + 1)≤Clog(n) whenever n>k we can conclude log(n2 + 1) is O(logn).


Is this correct? The book says that log(n2 + 1) is not O(logn).

I think you are right and your book is mistaken.
 

What is Big O notation?

Big O notation is a mathematical notation used to describe the asymptotic behavior or limiting behavior of a function. It is commonly used in computer science to analyze the time or space complexity of algorithms.

Why is it important to determine the Big O of a function?

Determining the Big O of a function helps us understand the time or space complexity of an algorithm and can aid in optimizing its performance. It also allows us to compare the efficiency of different algorithms and choose the most efficient one for a particular problem.

How do you determine the Big O of a function?

To determine the Big O of a function, you need to analyze its behavior as the input size increases. This is usually done by identifying the dominant term in the function and ignoring any lower-order terms or constants. The resulting expression is then simplified using Big O rules to determine the overall complexity.

What are some common Big O complexities?

The most common Big O complexities are O(1) for constant time, O(log n) for logarithmic time, O(n) for linear time, O(n^2) for quadratic time, and O(n!) for factorial time. There are also other complexities such as O(n^k) for polynomial time and O(2^n) for exponential time.

Are there any limitations to using Big O notation?

Yes, there are some limitations to using Big O notation. It only considers the worst-case scenario and does not take into account the best or average case. It also does not consider factors such as memory usage, input data, and hardware differences, which can affect the actual runtime of an algorithm. Therefore, it should be used as a guide and not the sole factor in determining the efficiency of an algorithm.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Precalculus Mathematics Homework Help
2
Replies
49
Views
4K
  • Mechanical Engineering
Replies
3
Views
936
  • Precalculus Mathematics Homework Help
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • General Math
Replies
16
Views
3K
Replies
6
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top