Asymptotic Analysis (original) (raw)

Last Updated : 9 Apr, 2026

**Given two algorithms for a task, how do we find out which one is better?

A naive approach is to implement both algorithms and compare their running times on different inputs, but this method has many drawbacks for analyzing algorithms.

Asymptotic analysis evaluates an algorithm’s performance based on input size, ignoring actual running time. It measures the order of growth of time or space; for example, linear search grows linearly, while binary search grows logarithmically.

Let us consider the search problem (searching a given item) in a sorted array.

The solution to above search problem includes:

**How is Asymptotic Analysis Machine Independent?

To understand how Asymptotic Analysis solves the problems mentioned above in analyzing algorithms,

Input Size Running time on A Running time on B
10 2 sec ~ 1 minutes
100 20 sec ~ 1.8 minutes
10^6 ~ 55.5 h ~ 5.5 minutes
10^9 ~ 6.3 years ~ 8.3 minutes

Running times for this example:

**Does Asymptotic Analysis always work?