wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quicksort. Hash Tables, and Binary Search Trees

Total questions: 18

Worksheet time: 13mins

Name
Class
Date
1.

What is the time complexity of the following code? (Click on image to view full screen)

a)

O(nlogn)

b)

O( 2n2^n  )

c)

O(n)

d)

O(1)

2.

What is the Time Complexity of the attached code?(Click on image to view full screen)

a)

O(n)

b)

O(1)

c)

O(log n)

d)

O( n2n^2  )

3.

What is the time complexity of the following code?(Click on image to view full screen)

a)

O( n2n^2  )

b)

O(1)

c)

O(n log n)

d)

O(n)

4.

What is the time complexity of the code?(Click on image to view full screen)

a)

O(1)

b)

O(n)

c)

O(n log n)

d)

O(2)

5.

What is the search complexity in direct addressing of hash tables?

a)

O(n)

b)

O(log n)

c)

O(n log n)

d)

O(1)

6.

What is the average run time for quick sort algorithm?

a)

O( n2n^2 )

b)

O(n)

c)

O(nlog n)

d)

O(log n)

7.

How many sub arrays does the quick sort algorithm divide the entire array into?

a)

One

b)

Two

c)

Four

d)

Three

8.

What is the worst case time complexity of the Quick sort?

a)

O(nlogn)

b)

O(n)

c)

O( n3n^3 )

d)

O( n2n^2 )

9.

In Order Traversal

a)

50 40 20 30 10

b)

40 50 20 30 10

c)

10 20 30 40 50

d)

40 20 50 10 30

10.

What is the worst case time complexity for search, insert and delete operations in a GENERAL Binary Search Tree?

a)

O(n) for all

b)

O(logn) for all

c)

O(logn) for search, insert and O(n) for delete

d)

O(logN)

11.

Complete this code

quicksort(A, p, r)

if p< r

q=partition(A, p,r)

quicksort(A, p, q-1)

(a)  

12.

What is a Collision Resolution Method for hash table:

a)

Linear Probing

b)

Primary Clustering

c)

Hashing

13.

What is the worst case time complexity for basic operations on a COMPLETE binary tree?

a)

O(n)

b)

O(logn)

c)

O( n2n^2 )

d)

O(1)

14.

For a Binary Search Tree, the left value is greater than the root

a)

True

b)

False

15.

Let us consider a list of numbers (34, 16, 2, 93, 80, 77, 51) and has a hash function of x % 10, what is the order of the elements ?

a)

null, null, 77, 16, null, 34, 93, 2, 51, 80

b)

77, 16, 34, 93, 2, 51, 80

c)

80, 51, 2, 93, 34, null, 16, 77, null, null

d)

80, 51, 2, 93, 34, 16, 77

16.

Is this a Binary Search Tree?

a)

Yes

b)

No

17.

Complete the code: (Answer in the format: answer, answer)

inorder-tree-walk(x)

if n NOT nil

inorder-tree-walk(___)

print x.key

inorder-tree-walk(___)

(a)  

18.

When is time complexity of Quicksort O( n2n^2  )?

a)

Pivot is the middle element.

b)

Too many elements.

c)

Pivot is the first element.

d)

Pivot is the highest or smallest element.