Search Header Logo

Time Complexity Review

Authored by Angel Coronel

Computers

University

Used 3+ times

Time Complexity Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?