wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DSA-Quiz1

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

In which of the following lists, the first node contains a pointer to the last node?

a)

Singly linked lists

b)

Circular linked lists

c)

Doubly linked lists

d)

Doubly circular linked lists

2.

If the sequence of operations performed on a stack is:

push(5), push (10),  pop, push (5), pop, pop, push (10), pop,

then what would be the sequence of popped values?

a)

10, 5, 5, 5

b)

10, 5, 5, 10

c)

5, 10, 10, 5

d)

5, 10, 5, 10

3.

Which of the following is the equivalent postfix expression for *+ p q – r s?

a)

pq + rs– *

b)

pq  rs + – *

c)

pq + rs* –

d)

pq  + – rs*

4.

On which principle does a stack work?

a)

LIFO

b)

FIFO

c)

FCFS

d)

None of the above

5.

Which of the following statements about queues is incorrect?

a)

Queues are first‐in, first‐out  (FIFO) data structures

b)

Queues can be implemented using arrays

c)

Queues can be implemented using linked lists

d)

New nodes can only be added at the front of the queue

6.

If you have an empty queue and you insert characters ‘r’, ‘a’, ‘t’ (in this order only), what is the order of the characters when you dequeue all the elements?

a)

‘r’, ‘a’, ‘t’

b)

‘t’, ‘a’, ‘r’

c)

‘r’, ‘t’, ‘a

d)

‘t’, ‘r’, ‘a’

7.

Which of the following is most suitable data structure to implement trees?

a)

Arrays

b)

Linked lists

c)

Stacks

d)

Queues

8.

Which of the following statements is true for binary search trees?

a)

a) The left subtree of a node contains only nodes with keys less than the node's key

b)

b) The right subtree of a node contains only nodes with keys greater than the node's key

c)

c) Both left and right subtree nodes contains only nodes with keys less than the node's key

d)

Both a) and b) are correct

9.

Which of the following traversals is used in in‐order traversal?

a)

root ‐> left subtree ‐> right subtree

b)

root ‐> right subtree ‐> left subtree

c)

left subtree ‐> root ‐> right subtree

d)

right subtree  ‐> left subtree ‐> root

10.

The height of a binary tree is the total number of nodes on the path from the root node to the deepest node in the tree.

The maximum number of nodes in a binary tree of height h is

a)

2h12^{h-1}  

b)

2h1  12^{h-1}\ -\ 1  

c)

2h12^h-1  

d)

2*(h+1)

11.

O-notation provides an asymptotic

a)

Lower bound

b)

Upper bound  

c)

Tight bound  

d)

None of the above

12.

Compute the time complexity of the following function written in C.

void function(int n) {

int i, count = 0;

for (i=1; i*i<=n ; i++)

count++;

}

a)

O(n)

b)

O( n2n^2 )

c)

O( n\sqrt[]{}n  )

d)

O(log n)