wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Code Nascar

Total questions: 30

Worksheet time: 8hrs 30mins

Name
Class
Date
1.

Which data structure gives O(1) time for both get() and put() in an LRU cache?

a)

Queue

b)

HashMap

c)

Doubly Linked List

d)

HashMap + Doubly Linked List

2.

Which algorithm is used for finding Strongly Connected Components (SCC)?

a)

Prim’s

b)

Kosaraju’s Algorithm

c)

Kruskal’s

d)

Topological Sort

3.

Which algorithm can be used for detecting bridges in a graph?

a)

BFS

b)

Tarjan's Algorithm

c)

Dijkstra

d)

Prim

4.

Which of the following is not an application of stack?

a)

Infix to postfix conversion

b)

Function call management

c)

BFS traversal

d)

Expression evaluation

5.

The minimum number of edges in a connected undirected graph with n vertices is:

a)

n

b)

n-1

c)

n+1

d)

2n

6.

Which of the following sorting algorithms is stable?

a)

QuickSort

b)

MergeSort

c)

HeapSort

d)

Selection Sort

7.

Which of the following data structures is best for implementing a priority queue?

a)

Stack

b)

Queue

c)

Heap

d)

Tree

8.

What is the time complexity of inserting an element in a heap?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n²)

9.

Which of the following is not true about a Red-Black Tree?

a)

It is a binary search tree

b)

It is balanced

c)

It requires rebalancing after insert/delete

d)

It allows duplicate keys

10.

Which traversal method is used by DFS?

a)

BFS

b)

Queue

c)

Stack

d)

Min Heap

11.

What is the time complexity to insert into a binary search tree (average case)?

a)

O(n)

b)

O(log n)

c)

O(1)

d)

O(n log n)

12.

In Union-Find, which optimization keeps the tree flat?

a)

Path Compression

b)

DFS

c)

Rank Balancing

d)

Greedy Linking

13.

Which of these operations is not efficient in a singly linked list?

a)

Insert at head

b)

Insert at tail

c)

Delete at head

d)

Delete at tail

14.

A complete binary tree with n nodes has height:

a)

O(n)

b)

O(log n)

c)

O(n log n)

d)

O(1)

15.

Which algorithm is used to find all pairs shortest path?

a)

Kruskal

b)

Floyd-Warshall

c)

DFS

d)

Prim

16.

Which of the following is used in Dijkstra’s algorithm for shortest path?

a)

Queue

b)

Min Heap

c)

Max Heap

d)

Stack

17.

Which of these can be used to detect a cycle in a directed graph?

a)

DFS with recursion stack

b)

Dijkstra’s algorithm

c)

BFS only

d)

Prim’s algorithm

18.

What is the auxiliary space complexity of Merge Sort?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

19.

The best-case time complexity of QuickSort is:

a)

O(n²)

b)

O(n log n)

c)

O(log n)

d)

O(n)

20.

Which data structure is used in Breadth First Search (BFS)?

a)

Stack

b)

Queue

c)

Tree

d)

Heap

21.

Which of the following is not a self-balancing binary search tree?

a)

Red-Black Tree

b)

AVL Tree

c)

B-Tree

d)

Binary Heap

22.

Which of the following uses Divide and Conquer?

a)

Dijkstra’s Algorithm

b)

Kruskal’s Algorithm

c)

Merge Sort

d)

Prim’s Algorithm

23.

In a max-heap, the largest element is:

a)

At the leaf

b)

In the middle

c)

At the root

d)

Undefined

24.

What is the height of an AVL Tree with n nodes?

a)

O(n)

b)

O(log n)

c)

O(1)

d)

O(n log n)

25.

Which algorithm is used to find a Minimum Spanning Tree?

a)

Dijkstra’s

b)

Prim’s

c)

Floyd-Warshall

d)

DFS

26.

What is the space complexity of an adjacency matrix for a graph with V vertices?

a)

O(V)

b)

O(V²

c)

O(log V)

d)

O(E)

27.

Which of the following operations can be done in O(1) in a hash table (on average)?

a)

Search

b)

Insert

c)

Delete

d)

All of the above

28.

In which traversal method is a binary search tree traversed to get the values in ascending order?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Level order

29.

What is the worst-case time complexity of Binary Search on a sorted array?

a)

O(n)

b)

O(log n)

c)

O(n log n)

d)

O(1)

30.

Which data structure is most suitable for implementing recursion?

a)

Queue

b)

Array

c)

Stack

d)

Linked List