wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DSA QUIZ-2

Total questions: 25

Worksheet time: 12mins

Name
Class
Date
1.

Which of the following is not a stable sorting algorithm?

a)

Bubble Sort

b)

Merge Sort

c)

Insertion Sort

d)

Selection Sort

2.

Running merge sort on an array of size n which is already sorted is

a)

O(n)

b)

O(logn)

c)

O(n logn)

d)

O(n^2)

3.

Consider the situation in which assignment operation is very costly. Which of the following sorting algorithm should be performed so that the number of assignment operations is minimized in general?

a)

Insertion sort

b)

Heap Sort

c)

Selection sort

d)

None

4.

The lower bound on the number of comparisons performed by comparison-based sorting algorithm is

a)

Ω (1)

b)

Ω (n)

c)

Ω (nlogn)

d)

Ω (n2)

5.

Which of the following is not a limitation of binary search algorithm?

a)

must use a sorted array

b)

requirement of sorted array is expensive when a lot of insertion and deletions are needed

c)

there must be a mechanism to access middle element directly

d)

binary search algorithm is not efficient when the data elements more than 1500.

6.

State True or False for internal sorting algorithms.

i) Internal sorting are applied when the entire collection if data to be sorted is small enough that the sorting can take place within main memory.

ii) The time required to read or write is considered to be significant in evaluating the performance of internal sorting.

a)

i-True, ii-True

b)

i-True, ii-False

c)

i-False, ii-True

d)

i-False, ii-False

7.

The height of a BST is given as h. Consider the height of the tree as the no. of edges in the longest path from root to the leaf. The maximum no. of nodes possible in the tree is?

a)

2^(h-1) -1

b)

2^(h+1) -1

c)

2^h +1

d)

2^(h-1) +1

8.

Suppose a binary tree is constructed with n nodes, such that each node has exactly

either zero or two children. The maximum height of the tree will be?

a)

(n+1)/2

b)

(n-1)/2

c)

n/2 -1

d)

(n+1)/2 -1

9.

Which of the following statement about binary tree is CORRECT?

a)

a) Every binary tree is either complete or full

b)

b) Every complete binary tree is also a full binary tree

c)

c) Every full binary tree is also a complete binary tree

d)

d) A binary tree cannot be both complete and full

10.

Suppose we have numbers between 1 and 1000 in a binary search tree and want to

search for the number 363. Which of the following sequence could not be the

sequence of the node examined?

a)

a) 2, 252, 401, 398, 330, 344, 397, 363

b)

b) 924, 220, 911, 244, 898, 258, 362, 363

c)

c) 925, 202, 911, 240, 912, 245, 258, 363

d)

d) 2, 399, 387, 219, 266, 382, 381, 278, 363

11.

Which type of traversal of binary search tree outputs the value in sorted order?

a)

a) Pre-order

b)

b) In-order

c)

c) Post-order

d)

d) both a) & b)

12.

A binary search tree is formed from the sequence 6, 9, 1, 2, 7, 14, 12, 3, 8, 18. The

minimum number of nodes required to be added in to this tree to form an extended binary tree is?

a)

a) 3

b)

b) 6

c)

c) 8

d)

d) 11

13.

In a full binary tree, every internal node has exactly two children. A full binary tree

with 2n+1 nodes contains

a)

a) n leaf node

b)

b) n-1 internal nodes

c)

c) n-1 leaf nodes

d)

d) n internal nodes

14.

the run time for traversing all the nodes of a binary search tree with n nodes and

printing them in an order is

a)

a) O(nlog(n))

b)

b) O(n)

c)

c) O(√n)

d)

d) O(log(n))

15.

If n numbers are to be sorted in ascending order in O(nlogn) time, which of the

following tree can be used

a)

a) Binary tree

b)

b) Binary search tree

c)

c) Max-heap

d)

d) Min-heap

16.

A threaded binary tree is a binary tree in which every node that does not have right

child has a thread to its

a)

a) Pre-order successor

b)

b) In-order successor

c)

c) In-order predecessor

d)

d) Post-order successor

17.

In which of the following tree, parent node has a key value greater than or equal to

the key value of both of its children?

a)

a) Binary search tree

b)

b) Threaded binary tree

c)

c) Complete binary tree

d)

d) Max-heap

18.

In-order traversing a tree resulted E A C K F H D B G; the pre-order traversal

would return.

a)

A. FAEKCDBHG

b)

B. FAEKCDHGB

c)

C. EAFKHDCBG

d)

D. FEAKDCHBG

19.

If node N is a terminal node in a binary tree then its .........

a)

A. Right tree is empty

b)

B. Left tree is empty

c)

C. Both left & right sub trees are empty

d)

D. Root node is empty

20.

What is the maximum height of any AVL-tree with 7 nodes? Assume that the height

of a tree with a single node is 0.

a)

A. 2

b)

B. 3

c)

C. 4

d)

D. 5

21.

Which of the below diagram is following AVL tree property?

a)

a) only i

b)

b) only i and ii

c)

c) only ii

d)

d) none of the mentioned

22.

If h is any hashing function and is used to hash n keys in to a table of size m, where n<=m, the expected number of collisions involving a particular key x is :

a)

a) Less than 1

b)

b) Less than n

c)

c) Less than m

d)

d) Less than n/2

23.

When is it appropriate to use direct addressing?

a)

A. When the array is comparatively large

b)

B. When the universe U of keys is reasonably small

c)

C. When the universe U of keys is reasonably large

d)

D. When the array is comparatively small

24.

What is the time complexity to delete an element from the direct address table?

a)

A. O(n)

b)

B. O(logn)

c)

C. O(nlogn)

d)

D. O(1)

25.

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