wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Data Structures Full

Total questions: 90

Worksheet time: 45mins

Name
Class
Date
1.

Which data structure follows the First-In-First-Out (FIFO) principle?

a)

Stack

b)

Queue

c)

Tree

d)

Graph

2.

In a stack, which operation adds an element to the top?

a)

push

b)

pop

c)

peek

d)

enqueue

3.

What is the time complexity of accessing an element in a linked list?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

4.

How many dimensions does a 2D array have?

a)

1

b)

2

c)

3

d)

4

5.

Which tree traversal visits the root node last?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Level order

6.

What is the maximum number of edges in a simple graph with n vertices?

a)

n

b)

n-1

c)

n(n-1)/2

d)

2^n

7.

Dijkstra's algorithm is used to find:

a)

Minimum spanning tree

b)

Shortest path

c)

Longest path

d)

Euler circuit

8.

Which graph traversal uses a stack?

a)

Breadth-First Search

b)

Depth-First Search

c)

Both

d)

Neither

9.

What is the time complexity of inserting an element at the end of a singly linked list?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

10.

In a binary tree, what is the maximum number of children a node can have?

a)

1

b)

2

c)

3

d)

Unlimited

11.

Which data structure is typically used to implement a breadth-first search?

a)

Stack

b)

Queue

c)

Linked List

d)

Array

12.

What is the space complexity of storing a graph using an adjacency matrix?

a)

O(V)

b)

O(E)

c)

O(V + E)

d)

O(V^2)

13.

In a min-heap, which element is always at the root?

a)

Largest element

b)

Smallest element

c)

Middle element

d)

Random element

14.

What is the time complexity of accessing an element in a 2D array given its indices?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n^2)

15.

What is the time complexity of accessing an element in an array?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

16.

Which of the following is not a valid operation on a queue?

a)

Enqueue

b)

Dequeue

c)

Peek

d)

Push

17.

In a doubly linked list, each node contains:

a)

Only data

b)

Data and one pointer

c)

Data and two pointers

d)

Only pointers

18.

What is the time complexity of inserting an element into a binary search tree?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

19.

Which graph traversal visits all vertices at the same level before moving to the next level?

a)

Depth-First Search

b)

Breadth-First Search

c)

Preorder Traversal

d)

Postorder Traversal

20.

What is the primary advantage of using a linked list over an array?

a)

Constant-time access to elements

b)

Better cache locality

c)

Dynamic size

d)

Less memory usage

21.

In Dijkstra's algorithm, what data structure is commonly used to select the next vertex?

a)

Stack

b)

Queue

c)

Priority Queue

d)

Linked List

22.

What is the time complexity of the best-case scenario for bubble sort?

a)

O(n)

b)

O(n log n)

c)

O(n^2)

d)

O(1)

23.

Which of the following is not a type of binary tree?

a)

Full binary tree

b)

Complete binary tree

c)

Perfect binary tree

d)

Circular binary tree

24.

What is the maximum number of nodes in a binary tree of height h?

a)

2^h

b)

2^(h+1) - 1

c)

h^2

d)

2h

25.

In a stack, which operation removes an element from the top?

a)

push

b)

pop

c)

peek

d)

enqueue

26.

What is the time complexity of searching for an element in an unsorted linked list?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

27.

Which of the following is not a property of a binary search tree?

a)

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

b)

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

c)

Both the left and right subtrees must be binary search trees

d)

The tree must be balanced

28.

What is the time complexity of inserting an element at the beginning of a singly linked list?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

29.

In a 2D array, how are elements typically accessed?

a)

array[column][row]

b)

array[row][column]

c)

array(row, column)

d)

array.get(row, column)

30.

Which of the following is not a valid graph representation?

a)

Adjacency Matrix

b)

Adjacency List

c)

Edge List

d)

Node Array

31.

What is the time complexity of Dijkstra's algorithm using a binary heap?

a)

O(V^2)

b)

O(E log V)

c)

O(V + E)

d)

O(E + V log V)

32.

In a binary tree, what is the relationship between the number of nodes (n) and the number of edges (e)?

a)

e = n

b)

e = n - 1

c)

e = n + 1

33.

Which of the following data structures can be used to check for balanced parentheses?

a)

Queue

b)

Stack

c)

Linked List

d)

Binary Tree

34.

What is the time complexity of accessing the middle element in a singly linked list?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

35.

In a graph, what is a vertex with no incoming edges called?

a)

Leaf

b)

Root

c)

Source

d)

Sink

36.

Which of the following is not a property of a queue?

a)

FIFO principle

b)

Enqueue operation

c)

Dequeue operation

d)

LIFO principle

37.

What is the space complexity of a singly linked list with n nodes?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

38.

In a binary search tree, where is the smallest element located?

a)

Root

b)

Leftmost leaf

c)

Rightmost leaf

d)

Middle node

39.

What is the time complexity of finding the degree of a vertex in a graph represented by an adjacency matrix?

a)

O(1)

b)

O(log V)

c)

O(V)

d)

O(E)

40.

Which of the following is not a type of graph traversal?

a)

Depth-First Search

b)

Breadth-First Search

c)

Binary Search

d)

Topological Sort

41.

What is the maximum number of edges in a tree with n nodes?

a)

n

b)

n - 1

c)

n + 1

d)

2n

42.

Which data structure is most suitable for implementing an undo feature in a text editor?

a)

Queue

b)

Stack

c)

Linked List

d)

Binary Tree

43.

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

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

44.

In a 2D array, what does array[i][j] represent?

a)

The element in the i-th column and j-th row

b)

The element in the i-th row and j-th column

c)

The sum of elements in row i and column j

d)

The product of elements in row i and column j

45.

Which of the following is not a balanced binary tree?

a)

AVL tree

b)

Red-Black tree

c)

B-tree

d)

Binary Search Tree

46.

What is the time complexity of finding the shortest path between all pairs of vertices in a graph using Floyd-Warshall algorithm?

a)

O(V^2)

b)

O(V^3)

c)

O(E log V)

d)

O(V E)

47.

In a linked list, what is the node that points to null called?

a)

Head node

b)

Tail node

c)

Middle node

d)

Sentinel node

48.

Which of the following is true about a stack?

a)

It follows FIFO principle

b)

Elements are added at the rear

c)

Elements are removed from the front

d)

It follows LIFO principle

49.

What is the time complexity of deleting an element from the middle of a doubly linked list?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

50.

In a binary tree, a node with no children is called:

a)

Root node

b)

Leaf node

c)

Internal node

d)

Parent node

51.

Which of the following is not a property of a minimum spanning tree?

a)

It connects all vertices

b)

It has no cycles

c)

It has the minimum total edge weight

d)

It always has a unique solution

52.

What is the time complexity of finding an element in a binary search tree?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

53.

In a graph, what is a vertex with no outgoing edges called?

a)

Leaf

b)

Root

c)

Source

d)

Sink

54.

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

a)

Array

b)

Linked List

c)

Heap

d)

Stack

55.

What is the time complexity of accessing an element in a circular queue?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

56.

In a 2D array, how many elements are there in total if the array has m rows and n columns?

a)

m + n

b)

m * n

c)

2(m + n)

d)

m^n

57.

Which of the following is not a valid operation on a binary search tree?

a)

Insertion

b)

Deletion

c)

Search

d)

Rotation

58.

What is the primary advantage of using an adjacency list over an adjacency matrix for graph representation?

a)

Faster edge weight updates

b)

Constant-time edge existence check

c)

Less memory usage for sparse graphs

d)

Easier implementation

59.

In Dijkstra's algorithm, what is used to keep track of the shortest known distance to each vertex?

a)

Queue

b)

Stack

c)

Array

d)

Hash table

60.

What is the time complexity of reversing a singly linked list?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

61.

Which of the following is true about a complete binary tree?

a)

All levels are completely filled

b)

All nodes have exactly two children

c)

All levels except possibly the last are completely filled

d)

It is always balanced

62.

What is the maximum number of edges in a directed acyclic graph (DAG) with n vertices?

a)

n

b)

n - 1

c)

n(n-1)/2

d)

n(n-1)

63.

Which of the following data structures is most suitable for implementing a cache with a "least recently used" (LRU) eviction policy?

a)

Array

b)

Stack

c)

Queue

d)

HashMap

64.

What is the time complexity of finding the height of a binary tree?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

65.

In a graph, what is a path that visits each vertex exactly once called?

a)

Euler path

b)

Hamilton path

c)

Shortest path

d)

Spanning tree

66.

Which of the following is not a property of a red-black tree?

a)

Every node is either red or black

b)

The root is always black

c)

Every leaf (NIL) is black

d)

Red nodes always have two black children

67.

What is the time complexity of the peek operation in a stack?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

68.

In a binary tree, what is the maximum number of nodes at level i?

a)

i

b)

2^i

c)

i^2

d)

2i

69.

Which of the following is not a valid way to implement a queue?

a)

Array

b)

Linked List

c)

Stack

d)

Circular Buffer

70.

What is the time complexity of finding the in-degree of a vertex in a graph represented by an adjacency list?

a)

O(1)

b)

O(V)

c)

O(E)

d)

O(V + E)

71.

In a min-heap, which of the following is always true?

a)

The root is the largest element

b)

The leaves are the smallest elements

c)

Each node is smaller than its children

d)

The tree is always balanced

72.

What is the space complexity of Dijkstra's algorithm?

a)

O(V)

b)

O(E)

c)

O(V^2)

d)

O(V + E)

73.

Which of the following data structures is most suitable for implementing a spell checker?

a)

Array

b)

Linked List

c)

Trie

d)

Stack

74.

What is the time complexity of inserting an element at a given position in an array?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

75.

In a graph, what is a cycle that visits each edge exactly once called?

a)

Euler circuit

b)

Hamilton circuit

c)

Shortest cycle

d)

Spanning cycle

76.

Which of the following is not a property of a B-tree?

a)

All leaves are at the same level

b)

A node can have a maximum of 2 children

c)

It is balanced

d)

It is used in databases and file systems

77.

What is the time complexity of the best case for quicksort?

a)

O(n)

b)

O(n log n)

c)

O(n^2)

d)

O(log n)

78.

In a 2D array, what does array.shape represent in Python (assuming NumPy is used)?

a)

The total number of elements

b)

The number of rows

c)

The number of columns

d)

A tuple of (number of rows, number of columns)

79.

Which of the following is true about a doubly linked list?

a)

It uses less memory than a singly linked list

b)

It allows for easier backward traversal

c)

It has faster insertion at the beginning

d)

It has constant time access to elements

80.

What is the primary purpose of a hash table?

a)

To sort elements

b)

To provide fast insertion and lookup

c)

To maintain a balanced tree structure

d)

To implement graph algorithms

81.

What is the time complexity of the union-find operation with path compression and union by rank?

a)

O(1)

b)

O(log n)

c)

O(α(n)), where α is the inverse Ackermann function

d)

O(n)

82.

Which of the following is not a valid tree traversal method?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Middleorder

83.

What is the primary advantage of using a circular queue over a simple queue?

a)

It uses less memory

b)

It allows for faster enqueue operations

c)

It prevents queue overflow by wrapping around

d)

It provides constant time access to all elements

84.

In graph theory, what is a tree?

a)

A connected graph with no cycles

b)

A disconnected graph with cycles

c)

A connected graph with exactly one cycle

d)

A graph with multiple roots

85.

What is the time complexity of finding the kth smallest element in a binary search tree?

a)

O(1)

b)

O(log n)

c)

O(k)

d)

O(n)

86.

Which of the following is true about a stack implemented using an array?

a)

It can never overflow

b)

It has a fixed maximum size

c)

It allows random access to elements

d)

It uses less memory than a linked list implementation

87.

What is the primary purpose of a sentinel node in a linked list?

a)

To mark the beginning of the list

b)

To simplify boundary conditions in algorithms

c)

To increase the speed of traversal

d)

To reduce memory usage

88.

In a max-heap, what is the relationship between a node at index i and its children?

a)

The node is smaller than its children

b)

The node is larger than its children

c)

The node is equal to its children

d)

There is no specific relationship

89.

What is the time complexity of finding all connected components in an undirected graph?

a)

O(V)

b)

O(E)

c)

O(V + E)

d)

O(V * E)

90.

Which of the following data structures is most suitable for implementing a filesystem directory structure?

a)

Array

b)

Linked list

c)

Tree

d)

Stack