Time Complexity Review

Time Complexity Review

University

11 Qs

quiz-placeholder

Similar activities

Algorithm analysis: divide & conquer theory

Algorithm analysis: divide & conquer theory

University

10 Qs

Sorting

Sorting

University

15 Qs

Quiz3_DivideConquer_GreedyApproach

Quiz3_DivideConquer_GreedyApproach

University

10 Qs

Searching and Sorting

Searching and Sorting

University

16 Qs

Quizze Buzzie

Quizze Buzzie

University

14 Qs

DSA Diaries 2.0

DSA Diaries 2.0

University

11 Qs

Viva - Practical - Main

Viva - Practical - Main

University

10 Qs

DAA_C_MCQ - 1

DAA_C_MCQ - 1

University

12 Qs

Time Complexity Review

Time Complexity Review

Assessment

Quiz

Computers

University

Medium

Created by

Angel Coronel

Used 3+ times

FREE Resource

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Which of the following best describes the differences between selection sort, merge sort, and insertion sort?

Selection sort repeatedly selects the smallest element, merge sort divides and merges, and insertion sort places each element into its correct position.

Merge sort uses recursion, selection sort uses dynamic programming, and insertion sort uses hash tables.

Selection sort and merge sort have the same time complexity, while insertion sort is the fastest in all cases.

Insertion sort and merge sort are cool, but selection sort is not.

Answer explanation

Selection sort finds the minimum element repeatedly

Merge sort divides and then merges sorted parts

Insertion sort places elements one at a time in the correct position

2.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What is the average time complexity of selection sort, merge sort, and insertion sort, respectiv

O(n²), O(n log n), O(n)

O(n log n), O(n²), O(n²)

O(n²), O(n log n), O(n²)

O(n log n), O(n log n), O(n log n)

Answer explanation

Selection and Insertion sorts have an average time complexity of O(n²) due to nested loops

Merge sort is more efficient at O(n log n) due to its divide-and-conquer approach

3.

FILL IN THE BLANK QUESTION

1 min • 1 pt

The time complexity of bubble sort is...

Answer explanation

Bubble sort has O(n²) time complexity on average due to the need for repeated passes through the array to swap adjacent elements until fully sorted

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Why does merge sort require additional space compared to selection and insertion sort?

Merge sort requires extra space for recursive calls.

Merge sort needs temporary arrays to merge sorted halves.

Merge sort only sorts in-place with no extra space.

Merge sort uses more memory due to inefficient looping.

Answer explanation

Merge sort divides the array and requires temporary storage for the sorted halves during merging, increasing its space complexity to O(n)

5.

FILL IN THE BLANK QUESTION

1 min • 1 pt

The time complexity of a nested for loop that iterates n times in outer-loop and 50 times in inner-loop is...

Answer explanation

A single loop iterates through each element once and does 50 calculations per element, resulting in linear time complexity, O(50*n) which is O(n)

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the time complexity to find an element in an unsorted singly linked list?

O(1)

O(n)

O(log n)

O(n²)

Answer explanation

In an unsorted linked list, you must traverse each node until the element is found, leading to O(n) time complexity.

7.

FILL IN THE BLANK QUESTION

1 min • 1 pt

An algorithm that divides its input in half with each recursive call, like binary search, has a time complexity of...

Answer explanation

Dividing the problem size by 2 with each step leads to a logarithmic number of calls

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?