Back to course home
0% completed
Analyzing Simple Algorithms
In this lesson, we’ll practice analyzing time complexity using two basic algorithms: finding the maximum element in a list and Insertion Sort. Both examples will reinforce the process of breaking down an algorithm and identifying the time complexity.
Example 1: Finding the Maximum Element in a List
Let’s start with a simple algorithm to find the maximum element in a list of n
numbers.
Algorithm Code
Step-by-Step Analysis
-
Initialization:
max_num = numbers[0]
- This assignment is constant and takes O(1) time.
-
Loop through the List:
.....
.....
.....
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