Data structure algorithem

Thread Starter

Ryan$

Joined Dec 14, 2018
178
Hi guys, sorry if this thread isn't suitable to post here but I've searched our forums and didn't find more suitable than this division, and if there's others forums that dealing with data structure algorithm then please gimme the link for that forum !

My question is about time complexity, what's the difference between T(n) and T(constant number) ? exactly what's more baffling me that
T(constant number)= Any Constant, why?! doesn't matter what's the argument of T, whenever the argument of T is a constant number then
T(constant number)=Constant , why is it equal to Constant?

I may miss understanding the definition of T( argument )


thanks for helpers
 

WBahn

Joined Mar 31, 2012
30,077
I think you might be talking about O() and not T() -- though it depends on the author you are reading from.

Usually T(n) is the maximum time (or other suitable metric, such as processor clock cycles or instructions executed) required to solve any instance of the problem of size n. This is usually a very complicated function and it is almost never actually determined.

O(n) is the asymptotic bound on T(n) as n goes towards infinity.

The definition of O() is the following:

f(n) = O(g(n))

if positive integers C and No exist such that for every integer n ≥ No

f(n) ≤ C·g(n)
 

Thread Starter

Ryan$

Joined Dec 14, 2018
178
I think you might be talking about O() and not T() -- though it depends on the author you are reading from.

Usually T(n) is the maximum time (or other suitable metric, such as processor clock cycles or instructions executed) required to solve any instance of the problem of size n. This is usually a very complicated function and it is almost never actually determined.

O(n) is the asymptotic bound on T(n) as n goes towards infinity.

The definition of O() is the following:

f(n) = O(g(n))

if positive integers C and No exist such that for every integer n ≥ No

f(n) ≤ C·g(n)
Firstly I appreciate your cooperative very much, and your definition of T(n) is exactly what my book defined ! (good approach brah :) )

secondly that's not the point that I'm asking about.

what I'm asking that in the book said because we have T(constant) meaning the argument of T is constant then the time complexity is "CONSTANT", I don't know why? is it because the argument of T is constant then the T(constant) is CONSTANT? if so why it's equal to constant? , to clear more the book said directly whenever the argument of T is a constant , T(constant), as it's equal to CONSTANT , i.e
T(constant)=CONSTANT;
to clear more what T of determined size constant is equal immediately CONSTANT ! but T of undetermined size like n isn't immediately CONSTANT !

**CONSTANT is a constant number .. **
 

WBahn

Joined Mar 31, 2012
30,077
Firstly I appreciate your cooperative very much, and your definition of T(n) is exactly what my book defined ! (good approach brah :) )

secondly that's not the point that I'm asking about.

what I'm asking that in the book said because we have T(constant) meaning the argument of T is constant then the time complexity is "CONSTANT", I don't know why? is it because the argument of T is constant then the T(constant) is CONSTANT? if so why it's equal to constant? , to clear more the book said directly whenever the argument of T is a constant , T(constant), as it's equal to CONSTANT , i.e
T(constant)=CONSTANT;
to clear more what T of determined size constant is equal immediately CONSTANT ! but T of undetermined size like n isn't immediately CONSTANT !

**CONSTANT is a constant number .. **
What is the time complexity of looking up a specific element in an array? It takes the same amount of time regardless of whether the array has 2 elements or 2 million elements. The amount of time is a constant independent of the value of n.

Now, it might be 10 ns or it might be 50 ms, but it is the same regardless of how big n is (within limits -- if n is so large that we have to swap memory pages or use virtual memory on the hard drive, then it is no longer constant -- but it's also not really the same problem).
 

Thread Starter

Ryan$

Joined Dec 14, 2018
178
What is the time complexity of looking up a specific element in an array? It takes the same amount of time regardless of whether the array has 2 elements or 2 million elements. The amount of time is a constant independent of the value of n.

Now, it might be 10 ns or it might be 50 ms, but it is the same regardless of how big n is (within limits -- if n is so large that we have to swap memory pages or use virtual memory on the hard drive, then it is no longer constant -- but it's also not really the same problem).
thanks you! got it!!
 
Top