Big-O Estimate for (n*logn + 1)^2 + (logn + 1)(n^2+1) - Homework Problem

  • Thread starter TheLegace
  • Start date
  • Tags
    Estimate
In summary, the conversation is about finding the Big-O estimate for the expression (n*logn + 1)^2 + (logn +1)(n^2+1). The person asking for help is struggling with calculating (n*logn)^2 and is looking for assistance. The expert provides a solution and states that the best big-O estimate for the expression is O( n^2 (log n)^2 ). The expert also mentions that the property log(n^2)=2 log n is not relevant in this problem.
  • #1
TheLegace
27
0

Homework Statement


Hi, I am trying to solve this problem:
I want the Big-O Estimate for this problem
(n*logn + 1)^2 + (logn +1)(n^2+1)

Homework Equations


now only real problem comes when I try to do the square of the first term.

I just don't know what (n*logn)^2 would be equal, it may be a it stupid, but it completely escapes my memory how to do it.

Checking on the calculator 2nlogn != (n*logn)^2 neither does n^2logn^2, so although it may be a little stupid, I just can't recall what that's equal to, I have been looking up log rules, but to no avail.

The Attempt at a Solution


To me it makes sense that (n*logn)^2 = 2n*log(n)
Thank You For Your Help.
 
Physics news on Phys.org
  • #2
(n log n)^2 is just n^2 (log n)^2.

Your best big-O estimate for (n*logn + 1)^2 + (logn +1)(n^2+1) is going to be
O( n^2 (log n)^2 ).

Of course, it is also O( n^3), or O( n^8 ), etc., but those aren't best.


[ You might be confusing yourself with the property log(n^2)=2 log n. This property doesn't come into play in this problem. ]
 

FAQ: Big-O Estimate for (n*logn + 1)^2 + (logn + 1)(n^2+1) - Homework Problem

What is a Big-O Estimate?

A Big-O Estimate is a way to measure the efficiency of an algorithm by analyzing its time complexity. It helps determine how the time taken to complete a task will increase as the input size increases.

Why is a Big-O Estimate important?

A Big-O Estimate is important because it allows us to compare the efficiency of different algorithms and choose the most efficient one for a given problem. It also helps in identifying bottlenecks in code and optimizing it for better performance.

How is a Big-O Estimate calculated?

A Big-O Estimate is calculated by analyzing the number of operations an algorithm performs as the input size increases. It focuses on the worst-case scenario and ignores constants and lower order terms.

What is the difference between O(1) and O(n) time complexity?

O(1) time complexity means that the algorithm's time taken to complete a task does not depend on the input size. On the other hand, O(n) time complexity means that the time taken to complete a task increases linearly with the input size.

Can a Big-O Estimate be used to compare algorithms with different time complexities?

Yes, a Big-O Estimate can be used to compare algorithms with different time complexities. However, it is important to keep in mind that it only considers the growth rate of the algorithm and not the actual time taken to complete the task. Other factors such as memory usage and implementation details should also be considered while comparing algorithms.

Back
Top