Quick sort algorithm

Quick sort algorithm

University

10 Qs

quiz-placeholder

Similar activities

Complexity Analysis Station [4]

Complexity Analysis Station [4]

University

6 Qs

Quiz 1 - Analysis of Algorithms

Quiz 1 - Analysis of Algorithms

University

5 Qs

ComplejidadAlgoritmos

ComplejidadAlgoritmos

University

8 Qs

Heaps

Heaps

University

15 Qs

Analisis Algoritma

Analisis Algoritma

University

10 Qs

Searching and Sorting

Searching and Sorting

University - Professional Development

15 Qs

DATA STRUCTURE-HEAP

DATA STRUCTURE-HEAP

University

12 Qs

DAA_C_MCQ_2

DAA_C_MCQ_2

University

10 Qs

Quick sort algorithm

Quick sort algorithm

Assessment

Quiz

Computers

University

Hard

Created by

anas alshorman

Used 97+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What is recurrence for worst case of QuickSort and what is the time complexity in Worst case?

Recurrence is T(n) = T(n-2) + O(n) and time complexity is O(n^2)

Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2)

Recurrence is T(n) = 2T(n/2) + O(n) and time complexity is O(nLogn)

Recurrence is T(n) = T(n/10) + T(9n/10) + O(n) and time complexity is O(nLogn)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using the above algorithm, then use median as pivot. What will be the worst case time complexity of this modified QuickSort.

O(n2 logn)O\left(n^2\ \log n\right)

O(n2)O\left(n^2\right)

O(n logn logn)O\left(n\ \log n\ \log n\right)

O(nlogn)O\left(n\log n\right)

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Let P be a QuickSort Program to sort numbers in ascending order using the first element as pivot. Let t1 and t2 be the number of comparisons made by P for the inputs {1, 2, 3, 4, 5} and {4, 1, 5, 3, 2} respectively. Which one of the following holds?

t1 = 5

t1 < t2

t1 > t2

t1 = t2

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You have an array of n elements. Suppose you implement quicksort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is

O(n2)

O(nLogn)

Theta(nLogn)

O(n3)

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using the above algorithm, then use median as pivot. What will be the worst case time complexity of this modified QuickSort.

O(n2 logn)O\left(n^2\ \log n\right)

O(n2)O\left(n^2\right)

O(n logn logn)O\left(n\ \log n\ \log n\right)

O(nlogn)O\left(n\log n\right)

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort?

O(n)O\left(n\right)

O(n logn)O\left(n\ \log n\right)

O (n2)O\ \left(n^2\right)

O (n!)O\ \left(n!\right)

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Quicksort is run on two inputs shown below to sort in ascending order taking first element as pivot,

(i) 1, 2, 3,......., n

(ii) n, n-1, n-2,......, 2, 1

Let C1 and C2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,

C1 < C2

C1 > C2

C1 = C2

We cannot say anything for arbitrary n

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?