Let Tn be the worstcase running time of an algorithm on an i

Let T(n) be the worst-case running time of an algorithm on an input of size n. Define what it means for T(n) to be O(n2). Give an example of O(n2) algorithm.

Solution

If T(n) is to be O(n2) it means O(N2) represents an algorithm whose performance is directly proportional to the square of the size of the input data . This is basically common in algorithms that involve nested iterations over the data set.

Example of O(n2) algorithm is Bubble sort algo that is used for sorting :

Complexity is O(n2)

Let T(n) be the worst-case running time of an algorithm on an input of size n. Define what it means for T(n) to be O(n2). Give an example of O(n2) algorithm.Sol

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site