If an algorithm has a loop that runs n times and performs O(1) operations in each iteration, what is the overall time complexity?

Algorithm Analysis and Design

Quiz
•
Engineering
•
University
•
Hard
EMMANUEL 210055
Used 1+ times
FREE Resource
24 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
O(1)
O(n)
O(n²)
O(log n)
2.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
Consider the following code snippet:
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cout << "Hello";
}
}
What is the time complexity?
O(n)
O(n log n)
O(n²)
O(n³)
3.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
What is the time complexity of the following algorithm?
int i = 1;
while (i < n) {
i = i * 2;
}
O(n)
O(log n)
O(n log n)
O(n²)
4.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
What is the time complexity of the recursive function below?
void func(int n) {
if (n <= 1) return;
func(n/2);
}
O(n)
O(log n)
O(n log n)
O(n²)
5.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
If a problem of size n is divided into two subproblems of size n/2 and combined in O(n) time, what is the overall time complexity using the Master Theorem?
O(n log n)
O(n²)
O(n)
O(log n)
6.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
What is the time complexity of inserting an element into a Binary Search Tree (BST) in the worst case?
O(1)
O(log n)
O(n)
O(n log n)
7.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
After inserting a new node in an AVL tree, which of the following operations might be required to maintain balance?
Only Left Rotation
Only Right Rotation
Either Left or Right Rotation
Left Rotation, Right Rotation, or Double Rotation
Create a free account and access millions of resources
Similar Resources on Quizizz
21 questions
Mastering Data Structures

Quiz
•
University
20 questions
Algorithm Time Complexity Quiz

Quiz
•
University
20 questions
Divide and Conquer & Dynamic Programming

Quiz
•
University
21 questions
Matematicas Discretas - Actividad en clase - 03 Abril 2025

Quiz
•
University
23 questions
Practica Primer Parcial

Quiz
•
University
20 questions
BE23CS407 - Design and Analysis of Algorithms (Unit-1)

Quiz
•
University
20 questions
DAA 4th Sem

Quiz
•
University
20 questions
Quiz Round For Group 2

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade