Mphasis Complexity Theory Quiz-1

Question 1

Time: 00:00:00
The worst-case complexity of quicksort is

O(n)

O(n)

O(log n)

O(log n)

O(n^2)

O(n^2)

O(n log n)

O(n log n)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
The complexity of merge sort is :

O(n)

O(n)

O(n logn)

O(n logn)

O(log n)

O(log n)

O(n^2)

O(n^2)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
The worst-case complexity for insertion sort is

O(n)

O(n)

O(log n)

O(log n)

O(nlogn)

O(nlogn)

O(n^2)

O(n^2)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
In data structure, time and space complexity by asymptotic notation. Which one of the following notation is not used to represent the same?

Big theta

Big theta

Big ohmega

Big ohmega

Big oh

Big oh

Big game

Big game

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
The worst-case occurs in quick sort when,

Pivot is the median of the array

Pivot is the median of the array

Pivot is the smallest element

Pivot is the smallest element

Pivot is the middle element

Pivot is the middle element

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
What does it mean when we say that an algorithm X is asymptotically more efficient than Y?

X will always be a better a better choice for large inputs

X will always be a better a better choice for large inputs

X will always be a better a better choice for smaller inputs

X will always be a better a better choice for smaller inputs

Y will always be a better a better choice for small inputs

Y will always be a better a better choice for small inputs

X will always be a better a better choice for all inputs

X will always be a better a better choice for all inputs

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What is the time, space complexity of following code ?

int a = 0, b = 0; 
for (i = 0; i < N; i++){
a = a + rand();
}
for (j = 0; j < M; j++){
b = b + rand();
}

O(N * M) time, O(1) space

O(N * M) time, O(1) space

O(N + M) time, O(N + M) space

O(N + M) time, O(N + M) space

O(N + M) time, O(1) space

O(N + M) time, O(1) space

O(N * M) time, O(N + M) space

O(N * M) time, O(N + M) space

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What is the time complexity of the following code:

int a = 0, i = N; 
while (i > 0)
{
a += i;
i /= 2;
}


O(N)

O(N)

O(Sqrt(N))

O(Sqrt(N))

O(N / 2)

O(N / 2)

O(log N)

O(log N)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What is the time complexity of the following code:

int i, j, k = 0; 
for (i = n / 2; i <= n; i++){
for (j = 2; j <= n; j = j * 2){
k = k + n / 2;
}
}

O(n)

O(n)

O(nLogn)

O(nLogn)

O(n^2)

O(n^2)

O(n^2Logn)

O(n^2Logn)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What is the time complexity of the following code:

int a = 0; 
for (i = 0; i < N; i++){
for (j = N; j > i; j--){
a = a + i + j;
}
}
}

O(N)

O(N)

O(N*log(N))

O(N*log(N))

O(N*log(N/2))

O(N*log(N/2))

O(N*N)

O(N*N)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%

Comments