What Determines the Asymptotic Time Complexity of T(n)=n^2+3?

In summary, the problem asks for an algorithm with ##T(n)=n^2+3## that has a complexity that is less than ##cf(n)## for all ##n>k##. The best choice for ##f(n)## is ##n^2##, and the best choice for ##c## is 2.
  • #1
gfd43tg
Gold Member
950
50

Homework Statement


In this question you will determine the asymptotic time complexity of an algorithm for which the complexity is ##T(n)=n^{2}+3##.

Find a positive real c and a positive integer ##k##, such that

##T(n) \le cf(n)##

holds for all ## n>k ## if ##f(n) ## is the asymptotic time complexity.

What is the best choice for ##f(n)##?

[ans]

What is a good choice for ##c## such that ##k## is small (i.e. less than 10)?What is ##k##?

Homework Equations


The Attempt at a Solution


I am confused how to approach these problems. Unfortunately the choices for ##f(n)## are not visible, there is a bug in the problem. But I was wondering what I should do in order to do these problems. The notes are not adequate (or available to look at, since that is bugged as well).
 
Physics news on Phys.org
  • #2
If there was a specific list of ##f(n)##'s that you don't have, then you're left guessing.
Commonly, the ##f(n)## is pretty simple, such as ##f(n) = e^n##, ##n^3##, or ##n^2##.

Among those choices, ##f(n) = n^2## would be best. Then use a c of 1.5 and a k of 3.
 
  • #3
You mean there is no way to analytically choose it?

The bug has been fixed, so the choices are
##n^2##, ##n##, ##nlog(n)##, and ##n^3##, so I pick ##n^2## since that is the closest to ##n^2 + 3##. Next, for ##k## being small (less than 10), I just do ## k = 9## and all ##n \gt 9##.

The choices for ##c## are 5, 0.5, 2, and 1, so I pick 2 since the inequality ##n^2 + 3 \le 2n^2## will be true for all ##n > 9##.

Next they ask what ##k## is, and the choices are 1, 10, 2, and 5. Well, what the heck do I do for that??
 
Last edited:
  • #4
Maylis said:
You mean there is no way to analytically choose it?

The bug has been fixed, so the choices are
##n^2##, ##n##, ##nlog(n)##, and ##n^3##, so I pick ##n^2## since that is the closest to ##n^2 + 3##. Next, for ##k## being small (less than 10), I just do ## k = 9## and all ##n \gt 9##.

The choices for ##c## are 5, 0.5, 2, and 1, so I pick 2 since the inequality ##n^2 + 3 \le 2n^2## will be true for all ##n > 9##.

Next they ask what ##k## is, and the choices are 1, 10, 2, and 5. Well, what the heck do I do for that??
Hey, I didn't do too bad at picking an ##f(n)## and ##c## without knowing the choices! Did I?

They want ##T(n)≤cf(n)## for all ##n>k##.
with ##T(n)=n^2+3## and ##cf(n)=2(n^2)##.
So, we have ##n^2+3 <= 2n^2## for all ##n>k##.

Clearly, if ##n=0##, then ##0^2+3 <= 2(0^2)##, so ##3<=0##, which is false. So ##n=0## doesn't work.

Let me know if you can't take it from there - I'll walk you through the rest.
 
  • #5
The problem I have with this is that when you pick ##c##, it's almost as if you are simultaneously supposing a ##k##. Are you supposed to pick the ##c## without regards to a possible ##k##?
 
  • #6
Maylis said:
The problem I have with this is that when you pick ##c##, it's almost as if you are simultaneously supposing a ##k##.
What you should notice is that as long as ##c## is greater than 1, there will be a ##k##. If ##c## is one or less, then ##T(N)## will always be greater than ##cf(n)##. So, without a list to choose from, I picked ##c=1.5## which would have required ##n>2 (k=2)##. Notice that in this case, even a ##c## that is slightly above 1, allows k to be fairly small.
Maylis said:
Are you supposed to pick the ##c## without regards to a possible ##k##?
This is pretty much just an academic exercise. For most real applications, it would be good enough to say that it was approximates ##cn^2## without worrying about the exact value of ##c##.
 

What is asymptotic time complexity?

Asymptotic time complexity is a measure of how the runtime of an algorithm increases as the input size grows towards infinity. It describes the upper bound of the algorithm's runtime and is often represented using big O notation.

Why is asymptotic time complexity important?

Asymptotic time complexity allows us to compare the efficiency of different algorithms and choose the most efficient one for a given problem. It also helps us understand how an algorithm will perform as the input size increases, allowing us to anticipate and optimize for larger inputs.

What is the difference between best, worst, and average case time complexity?

Best case time complexity describes the algorithm's runtime when the input is in the most ideal state. Worst case time complexity describes the algorithm's runtime when the input is in the least ideal state. Average case time complexity is the expected runtime for a random input. Asymptotic time complexity usually refers to worst case time complexity.

How is asymptotic time complexity calculated?

Asymptotic time complexity is calculated by analyzing the algorithm's operations and determining how many times they will be executed as the input size increases. This is often done using mathematical proofs and can be simplified to a single expression using big O notation.

Can two algorithms have the same asymptotic time complexity?

Yes, two algorithms can have the same asymptotic time complexity even if their actual runtimes are different. This is because asymptotic time complexity only describes the growth rate of the algorithm's runtime as the input size increases, not the actual runtime.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
912
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
346
  • Linear and Abstract Algebra
Replies
11
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Differential Equations
Replies
1
Views
752
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top