Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the notation T(n) mean?

Tags:

notation

We learned about big O notation, but I often see T(n) as well. For example,

public static Comparable[] mergeSort(Comparable[] A, int low, int high) {
  if (low < high) { //at least 2 elements?                //cost = c
    int mid = (low + high)/2;                             //cost = d
    Comparable[] A1 = mergeSort(A, low, mid);             //cost = T(n/2) + e
    Comparable[] A2 = mergeSort(A, mid+1, high);          //cost = T(n/2) + f
    return merge(A1,A2);                                  //cost = g n + h
  }
  .... //cost = i

I believe c,d,e,... are meant to be arbitrarily named constants.

What does T(n/2) mean? also how is T notation related to big O?

like image 921
James Avatar asked Nov 29 '12 03:11

James


People also ask

What does t/n mean in algorithm?

When we say that an algorithm runs in time T(n), we mean that T(n) is an upper bound on the running time that holds for all inputs of size n. This is called worst-case analysis. The algorithm may very well take less time on some inputs of size n, but it doesn't matter.

What does Ω n mean?

Similar to big O notation, big Omega(Ω) function is used in computer science to describe the performance or complexity of an algorithm. If a running time is Ω(f(n)), then for large enough n, the running time is at least k⋅f(n) for some constant k. Here's how to think of a running time that is Ω(f(n)):

What does t n )= O f'n )) mean?

In essence: T(n) ∊ O(f(n)) means that T(n) doesn't grow faster than f(n).

What is t/n time complexity?

The time complexity, measured in the number of comparisons, then becomes T(n) = n - 1. In general, an elementary operation must have two properties: There can't be any other operations that are performed more frequently as the size of the input grows.


1 Answers

This notation refers to the maximum amount of time (or, more specifically, steps) that a function takes to run.

T(n) may be much more specific than O(n); for example, let's say you have a program that for any input, requires n^2+n+1 steps to run:

T(n) = n^2+n+1
O(n) = n^2

More information can be found here.

like image 185
username tbd Avatar answered Oct 19 '22 03:10

username tbd