wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CYBERSYNAPSE

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following sorting algorithms has the best worst-case time complexity?

a)

Merge Sort

b)

Quick Sort

c)

Bubble Sort

d)

Selection Sort

2.

Which algorithm is used to find the shortest path in an unweighted graph?

a)

Bellman-Ford Algorithm

b)

Kruskal’s Algorithm

c)

Dijkstra’s Algorithm

d)

Breadth-First Search

3.

Which data structure is best suited for implementing a priority queue?

a)

Stack

b)

Queue

c)

Heap

d)

Graph

4.

In hashing, which technique is used to reduce collisions by mapping two keys to different slots?

a)

Open Addressing

b)

Chaining

c)

Dynamic Rehashing

d)

Dynamic Rehashing

5.

What is the time complexity of following code?

int a = 0, i = N;

while (i > 0) {

a += i; i /= 2;

}

a)

O(sqrt(N) )

b)

O(log(N))

c)

O(N)

d)

O(N/2)

6.

The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array?

a)

4

b)

2

c)

1

d)

0

7.

Consider a binary tree with n nodes, where each node can have at most two children. The height of the tree is defined as the maximum number of edges between the root node and any leaf node. Which of the following statements is true regarding the height h of this binary tree?

a)

The height of the tree is always equal to n-1

b)

The height of the tree can be greater than or equal to n-1

c)

The height of the tree is always equal to log₂(n)

d)

The height of the tree can be greater than or equal to log₂(n)

8.

Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an initially empty binary search tree. The binary search tree uses the usual ordering on natural numbers. What is the in-order traversal sequence of the resultant tree

a)

7 5 1 0 3 2 4 6 8 9

b)

0 2 4 3 1 6 5 9 8 7

c)

0 1 2 3 4 5 6 7 8 9

d)

9 8 6 4 2 3 0 1 5 7

9.

B+ Trees are considered BALANCED because

a)

the lengths of the paths from the root to all leaf nodes are all equal

b)

the lengths of the paths from the root to all leaf nodes differ from each other by at most 1

c)

the number of children of any two non-leaf sibling nodes differ by at most 1

d)

the number of records in any two leaf nodes differ by at most 1

10.

Which operation has a worse time complexity in a dynamic array when it needs to expand its size?

a)

Accessing an element by index

b)

Appending an element at the end

c)

Inserting an element at the beginning

d)

Searching for an element

11.

Inserting an element at the beginning

a)

By checking if the next pointer of any node is null

b)

Using a hash table to store visited nodes

c)

Comparing each node with every other node

d)

Using two pointers at different speeds

12.

Which data structure is most efficient for implementing a priority queue?

a)

Binary search tree

b)

Binary heap

c)

Linked list

d)

Hash table

13.

What technique is commonly used in dynamic programming to optimize recursive algorithms?

a)

Memoization

b)

Randomization

c)

Backtracking

d)

Linear search

14.

The data structure used to check whether an expression contains a balanced parenthesis is?

a)

Queue

b)

Stack

c)

Tree

d)

Array

15.

Given an undirected graph G with V vertices and E edges, what will be the sum of the degrees of all vertices?

a)

E

b)

2E

c)

V + E

d)

2V