Time complexity

Time complexity

University

10 Qs

quiz-placeholder

Similar activities

CodeCadette

CodeCadette

University

15 Qs

[LOGICAL AND AIRTHMETIC OPERATORS | AVERAGE]

[LOGICAL AND AIRTHMETIC OPERATORS | AVERAGE]

University

15 Qs

Algorithms - Time Complexity

Algorithms - Time Complexity

University

10 Qs

Expert Module Python

Expert Module Python

University

10 Qs

BCSC0006 - Quiz 2 - Big-Oh Notation

BCSC0006 - Quiz 2 - Big-Oh Notation

University

10 Qs

Quiz 6

Quiz 6

University

10 Qs

Python String Slice

Python String Slice

4th Grade - University

10 Qs

PHP Tours Meetup #44 Clean Code & Retours Forum PHP

PHP Tours Meetup #44 Clean Code & Retours Forum PHP

University

10 Qs

Time complexity

Time complexity

Assessment

Quiz

Computers

University

Medium

Created by

Hemalatha Chennai

Used 60+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def f()

ans = 0

for i = 1 to n:

for j = 1 to log(i):

ans += 1

print(ans)

Time Complexity of this program:

O(n)

O(nlogn)

O(n^2)

O(n^3)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def f():

a = 0

for i = 1 to n:

a += i;

b = 0

for i = 1 to m:

b += i;

Time Complexity of this program:

O(n)

O(m)

O(n+m)

O(nm)

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def f():

a = 0

for i = 1 to n:

a += random.randint();

b = 0

for j = 1 to m:

b += random.randint();

Time Complexity of this program:

O(n)

O(m)

O(n+m)

O(nm)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def f():

int a[n][n]

// Finding sum of elements of a matrix that are above or on the diagonal.

sum = 0

for i = 1 to n:

for j = i to n:

sum += a[i][j]

print(sum)

Time Complexity of this program:

O(n)

O(nlogn)

O(n^2)

O(n^3)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def f():

int a[n][n]

sum = 0

// Finding sum of elements of a matrix that are strictly above the diagonal.

for i = 1 to n:

for j = i to n:

sum += a[i][j]

print(sum)

for i = 1 to n:

sum -= a[i][i]

Time Complexity of this program:

O(n)

O(nlogn)

O(n^2)

O(n^3)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def f():

ans = 0

for i = 1 to n:

for j = n to i:

ans += (i * j)

print(ans)

Time Complexity of this program:

O(n)

O(nlogn)

O(n^2)

O(n^3)

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def f():

int a[N + 1][M + 1][K + 1]

sum = 0

for i = 1 to N:

for j = i to M:

for k = j to K:

sum += a[i][j]

print(sum)

Time Complexity of this program:

O(N+M+K)

O(NMK)

O(NM+K)

O(N+MK)

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?