wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Stacks, Queues, Trees, and Graphs Quiz

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

What is a stack based on?

a)

FIFO principle

b)

LIFO principle

c)

Random access

d)

Priority order

2.

Which operation adds an element to the stack?

a)

Push

b)

Pop

c)

Peek

d)

Enqueue

3.

Which operation removes the top element from a stack?

a)

Pop

b)

Push

c)

Peek

d)

Enqueue

4.

What is the primary application of stacks?

a)

CPU scheduling

b)

Expression evaluation

c)

Shortest path algorithms

d)

Network routing

5.

Which operation adds an element to a queue?

a)

Dequeue

b)

Enqueue

c)

Pop

d)

Peek

6.

Which operation removes an element from a queue?

a)

Enqueue

b)

Pop

c)

Dequeue

d)

Peek

7.

A queue works on which principle?

a)

LIFO

b)

FIFO

c)

Random access

d)

Last priority

8.

Which data structure is used to manage function calls in recursion?

a)

Queue

b)

Stack

c)

Graph

d)

Tree

9.

Circular queues solve which problem of linear queues?

a)

Stack overflow

b)

Queue underflow

c)

Wasted memory space

d)

Binary search

10.

Which of the following is an application of queues?

a)

Undo operation in editors

b)

CPU scheduling

c)

Parenthesis matching

d)

Expression evaluation

11.

What is a tree in data structures?

a)

A non-linear hierarchical structure

b)

A linear structure

c)

A graph with cycles

d)

A sequential structure

12.

In a binary tree, each node has at most how many children?

a)

1

b)

2

c)

3

d)

4

13.

In a binary search tree (BST), the left child is always:

a)

Smaller than the parent

b)

Greater than the parent

c)

Equal to the parent

d)

Random

14.

In a BST, the right child is always:

a)

Smaller than the parent

b)

Greater than the parent

c)

Equal to the parent

d)

Random

15.

Which traversal method visits nodes in sorted order in a BST?

a)

Preorder

b)

Postorder

c)

Inorder

d)

Level order

16.

What is the root of a tree?

a)

The bottom node

b)

The topmost node

c)

A leaf node

d)

A sibling node

17.

Which tree traversal visits root first, then left and right subtrees?

a)

Inorder

b)

Preorder

c)

Postorder

d)

Level order

18.

Which tree traversal visits left, right, then root?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Level order

19.

Which node in a tree has no children?

a)

Root

b)

Internal node

c)

Leaf node

d)

Parent node

20.

Which traversal is also called Depth-First Search (DFS) in trees?

a)

Preorder, Inorder, Postorder

b)

Level order

c)

Breadth-First

d)

Random

21.

What is a heap?

a)

A special binary tree

b)

A linked list

c)

A graph

d)

A queue

22.

In a max-heap, the root node is always:

a)

The smallest element

b)

The largest element

c)

Random

d)

Equal to children

23.

In a min-heap, the root node is always:

a)

The largest element

b)

The smallest element

c)

Equal to children

d)

Random

24.

Priority queues are often implemented using:

a)

Linked list

b)

Heap

c)

Stack

d)

Array only

25.

Which is an application of heaps?

a)

Sorting (Heap Sort)

b)

Expression evaluation

c)

Network protocols

d)

DFS traversal

26.

What is the time complexity to insert into a heap?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n²)

27.

Which operation retrieves the highest priority element in a max-heap?

a)

Delete root

b)

Insert

c)

Peek root

d)

Swap

28.

Which operation maintains heap structure after deletion?

a)

Re-heapify

b)

Insert

c)

Traverse

d)

Rotate

29.

A priority queue gives preference to:

a)

First entered data

b)

Data with highest priority

c)

Last entered data

d)

Random choice

30.

Which sorting algorithm uses heap?

a)

Merge sort

b)

Quick sort

c)

Heap sort

d)

Bubble sort

31.

What is a graph in data structures?

a)

A set of nodes and edges

b)

A tree

c)

A queue

d)

A stack

32.

In a graph, nodes are called:

a)

Roots

b)

Vertices

c)

Edges

d)

Leafs

33.

In a graph, connections are called:

a)

Vertices

b)

Edges

c)

Roots

d)

Levels

34.

A graph with no cycles is called:

a)

Cyclic graph

b)

Acyclic graph

c)

Weighted graph

d)

Directed graph

35.

A graph where edges have directions is called:

a)

Directed graph

b)

Undirected graph

c)

Weighted graph

d)

Tree

36.

A graph where edges have weights is called:

a)

Directed graph

b)

Weighted graph

c)

Undirected graph

d)

Heap

37.

Which algorithm explores nodes level by level?

a)

DFS

b)

BFS

c)

Dijkstra

d)

Bellman-Ford

38.

Which algorithm explores as far as possible along one branch?

a)

BFS

b)

DFS

c)

Dijkstra

d)

Kruskal

39.

Which data structure is used in BFS?

a)

Stack

b)

Queue

c)

Heap

d)

Tree

40.

Which data structure is used in DFS?

a)

Queue

b)

Stack

c)

Heap

d)

Linked list

41.

Which algorithm finds the shortest path in weighted graphs?

a)

BFS

b)

DFS

c)

Dijkstra

d)

Kruskal

42.

Which graph algorithm is used in minimum spanning tree (MST)?

a)

BFS

b)

DFS

c)

Kruskal or Prim's

d)

Bellman-Ford

43.

BFS is also known as:

a)

Depth-first traversal

b)

Breadth-first traversal

c)

Shortest path algorithm

d)

Priority traversal

44.

DFS is also known as:

a)

Level order traversal

b)

Depth-first traversal

c)

Shortest path algorithm

d)

Priority traversal

45.

What is the time complexity of BFS?

a)

O(V + E)

b)

O(V²)

c)

O(E log V)

d)

O(V log E)

46.

What is the time complexity of DFS?

a)

O(V + E)

b)

O(V²)

c)

O(E log V)

d)

O(V log E)

47.

Which graph representation uses adjacency list?

a)

Array only

b)

Linked lists for neighbors

c)

2D matrix

d)

Trees

48.

Which graph representation uses adjacency matrix?

a)

2D array

b)

Linked list

c)

Tree

d)

Heap

49.

Which traversal guarantees visiting all vertices in a connected graph?

a)

BFS or DFS

b)

Heap sort

c)

Queue traversal

d)

Dijkstra

50.

Which graph algorithm is widely used in GPS navigation systems?

a)

BFS

b)

DFS

c)

Dijkstra

d)

Heap sort