Examples Related to Time Complexities
Let's dive deeper into the time complexity analysis by looking into some examples in this lesson.
We'll cover the following
- Example 1: for loop
- Example 2: Nested for loop
- Example 3: Arithmetic series
- Example 4: Double the iteration variable
- Example 5: Half the iteration variable
- Example 6: Square root iteration
- Example 7: Nested loop in O(n)
- Example 8: Arithmetic progression
- Example 9: Triple nested loop
- Example 10: Multiple loops in O(n)
Letās dive deeper into the time complexity analysis by looking at some examples.
Example 1: for
loop
The case below is a for loop. We have a time complexity of .
Get hands-on with 1400+ tech skills courses.