wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SMARTICUS

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

If the post order traversal gives a b - c d * + then the label of the nodes 1, 2, 3 ... will be

a)

   +, -, *, a, b, c, d

b)

   a, -, b, +, c, *, d

c)

   a, b, c, d, -, *, +

d)

  -, a, b, +, *, c, d

2.

What is the time complexity for adding an element to a heap?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

3.

Which data structure is used to implement depth-first search in a graph?

a)

Array

b)

Linked List

c)

Stack

d)

Queue

4.

Which of the following operations on a heap data structure has the worst-case time complexity of O(log n)?

a)

Insertion

b)

Deletion

c)

Search

d)

Heapify

5.

Which of the following is the correct formula to calculate the index of a node's parent in a binary heap?

a)

i/2

b)

2i

c)

2i+1

d)

i-1

6.

The postfix form of the expression (A B)*(C*D− E)*F / G is

a)

AB CD* E − F **G /

b)

AB CD*E − FG /**

c)

AB CDE F *G /

d)

AB CD* E − F G / 

7.

What is a cycle in a graph?

a)

A set of vertices that are all connected to each other.

b)

A path in the graph that starts and ends at the same vertex.

c)

A group of edges that connect two different vertices.

d)

A subgraph that is disconnected from the main graph.

8.

A binary tree is generated by inserting in order the following integers:

50, 15, 62, 5, 20,58, 91, 3,8,37, 60, 24

The number of nodes in the left and right of the root respectively is

a)

(4,7)

b)

(7,4)

c)

(6,3)

d)

(3,6)

9.

What is the time complexity of sorting an array using bubble sort?

a)

O(1)

b)

O(n)

c)

O(n log n)

d)

O(n^2)

10.

Which of the following data structures is commonly used in conjunction with a suffix array to perform efficient pattern matching?

a)

Trie

b)

Hash table

c)

Bloom filter

d)

Skip list

11.

Which of the following algorithms is commonly used to construct a suffix array?

a)

Bubble sort

b)

Merge sort

c)

Quick sort

d)

Radix sort

12.

A binary tree in which every non-leaf node has non-empty left and right subtrees is called a strictly binary tree. Such a tree with 10 leaves

a)

cannot have more than 19 nodes

b)

has exactly 19 nodes

c)

has exactly 17 nodes

d)

cannot have more than 17 nodes

13.

What is the main advantage of using a Treap over other data structures such as AVL trees or red-black trees?

a)

Treaps have a simpler implementation.

b)

Treaps have a lower expected height, resulting in faster operations.

c)

Treaps have better worst-case time complexity.

d)

Treaps are easier to balance.

14.

Which of the following is an advantage of using abstract data types?

a)

They are easy to implement.

b)

They provide a clear separation of concerns between the implementation and the interface

c)

They are only used in low-level programming languages.

d)

They are always more efficient than using concrete data types.

15.

A priority queue is used to implement a stack S that stores characters PUSH(C)is implemented as INSERT(Q,C,K)where K is an appropriate integer key chosen by the implementation. POP is implemented as DELETEMIN(Q). For a sequence of operations, the key chosen are in

a)

Non-increasing order

b)

Non-decreasing order

c)

Strictly increasing order

d)

Strictly decreasing order

16.

The initial configuration of a queue is a, b, c, d, ('a' is in the front end). To get the configuration d, c, b, a, one needs a minimum o

a)

2 deletions and 3 additions

b)

3 deletion and 2 additions

c)

3 deletions and 3 additions

d)

3 deletions and 4 additions

17.

The depth of a complete binary tree with 'n nodes is (log is to be base two)

a)

log (n+1)-1

b)

log(n)

c)

log (n-1) + 1

d)

log(n) + 1

18.

What is the time complexity of inserting an element into a binomial queue of size n?

a)

O(log n)

b)

O(n)

c)

O(log^2 n)

d)

O(1)

19.

Which of the following sorting algorithms has the worst-case time complexity of O(n^2)?

a)

Merge Sort

b)

Quick Sort

c)

Insertion Sort

d)

Radix Sort

20.

Consider the following nested representation of binary trees indicates y and z are the left right subtrees, respectively, of node x. Note that y and z may be NULL or further nested. Which of the following represents a valid binary tree?

a)

(1 2(4 5 6 7))

b)

1((2 3 NULL)4 5 6)7)

c)

(1(234)(567)

d)

(1(2 3 NULL)(4 5))