Grokking Algorithm Complexity and Big-O
Ask Author
Back to course home

0% completed

Linear Time: O(n)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Linear Time Complexity O(n) describes algorithms where the runtime grows directly in proportion to the input size. This means that as the input size doubles, the time taken by the algorithm also doubles.

Key Characteristics

In an algorithm with O(n) time complexity:

  • The number of steps the algorithm takes grows linearly with the input size.
  • This is common in algorithms that need to examine every element of the input, like searching or filtering.

Code Example

Let’s look at an example of an O(n) algorithm

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible