How many operations can an average computer perform in less than a second?
10^8 operations.
What is the time complexity of a function that always performs a fixed number of operations?
Constant time — O(1).
1/29
p.3
Exponential and Factorial Time Complexities

How many operations can an average computer perform in less than a second?

10^8 operations.

p.2
Comparison of Time Complexities

What is the time complexity of a function that always performs a fixed number of operations?

Constant time — O(1).

p.3
Exponential and Factorial Time Complexities

What is the expected time complexity for n approximately equal to 1,000,000?

O(n) or O(n log n).

p.1
Big-O Notation and Its Importance

What is the time complexity of the provided function in Big-O notation?

O(n) — linear complexity.

p.2
Comparison of Time Complexities

In logarithmic time complexity O(log n), how does the value of n change with each iteration?

The value of n is halved on each iteration.

p.4
Constant Time Complexity - O(1)

What is the time complexity of the model solution?

O(1).

p.3
Space Complexity and Its Calculation

What does space complexity include?

All variables, both global and local, dynamic pointer data-structures, and stack contents in recursion.

p.2
Comparison of Time Complexities

What is the time complexity of a function that iterates over two different inputs n and m?

Linear time — O(n + m).

p.1
Dominant Operations in Algorithms

In the provided code, which line contains the dominant operation?

Line 4, where 'result += 1' is executed.

p.4
Quadratic Time Complexity - O(n^2)

What is the time complexity of the slow solution?

O(n^2).

p.1
Introduction to Time Complexity

Why is accurately calculating a program's operation time labor-intensive?

It depends on the compiler and the type of computer or speed of the processor.

p.4
Dominant Operations in Algorithms

How does the fast_solution function calculate the result?

It increments the result by (i + 1) for each index i.

p.3
Space Complexity and Its Calculation

What is the space complexity for declaring an array with n elements?

O(n).

p.4
Dominant Operations in Algorithms

What does the slow_solution function do?

It increments the result by 1 for each pair of indices (i, j).

p.1
Dominant Operations in Algorithms

What does complexity represent in the context of time complexity?

The maximum number of primitive operations that a program may execute.

p.3
Space Complexity and Its Calculation

Why is space complexity trickier to calculate than time complexity?

Not all variables and data-structures may be needed at the same time.

p.3
Space Complexity and Its Calculation

What is the space complexity for a program with a constant number of variables?

O(1).

p.2
Comparison of Time Complexities

What is the time complexity of a nested loop where both loops iterate n times?

Quadratic time — O(n^2).

p.4
Comparison of Time Complexities

What is the advantage of the model solution over the others?

It computes the result in constant time O(1).

p.4
Linear Time Complexity - O(n)

What is the time complexity of the fast solution?

O(n).

p.3
Exponential and Factorial Time Complexities

What is the expected time complexity for n approximately equal to 500?

O(n^3).

p.3
Exponential and Factorial Time Complexities

What are the two types of time complexity mentioned that can only solve problems for small values of n?

Factorial time O(n!) and exponential time O(2^n).

p.3
Exponential and Factorial Time Complexities

What is the expected time complexity for n approximately equal to 10,000?

O(n^2).

p.2
Comparison of Time Complexities

What is the worst-case time complexity for the linear function that checks for a zero in an array?

Linear time — O(n).

p.4
Dominant Operations in Algorithms

How does the model_solution function compute the result?

It uses the formula n * (n + 1) // 2.

p.1
Comparison of Time Complexities

What should be considered when analyzing the complexity of a program?

Specific, worst-case examples of data that the program will take a long time to process.

p.1
Introduction to Time Complexity

What is the purpose of using time complexity?

To estimate the running time of a program.

p.1
Big-O Notation and Its Importance

What does the complexity O(n) imply about the number of operations?

The program may perform c · n operations, where c is a constant.

p.1
Dominant Operations in Algorithms

What are dominant operations?

Operations that are performed the largest number of times in a program.

Study Smarter, Not Harder
Study Smarter, Not Harder