wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Trees and Graphs

Total questions: 85

Worksheet time: 1hrs 4mins

Name
Class
Date
1.

What is the preorder traversal of the given binary tree?

a)

A B D E H I J K L C F G

b)

A B D H I E J K C F L G

c)

H D I B J E K A L F C G

d)

H I D J K E B L F G C A

2.

What is the postorder traversal of the given binary tree?

a)

H D I B J E K A L F C G

b)

H I D J K E B L F A C G

c)

H I D J K E B L F G C A

d)

A B C D H I E J K F L G

3.

What is LR Rotation?

a)

Inserted node is in the left subtree of left subtree of node A

b)

Inserted node is in the right subtree of right subtree of node A

c)

Inserted node is in the right subtree of left subtree of node A

d)

Inserted node is in the left subtree of the right subtree of node A

4.

What is an AVL tree?

a)

a tree which is balanced and is a height balanced tree

b)

a tree which is unbalanced and is a height balanced tree

c)

a tree with three children

d)

a tree with atmost 3 children

5.

Why do we need AVL tree?

a)

To save memory

b)

To avoid formation of skewed trees

c)

To simplify storing

d)

To attain faster memory access

6.

Which of the following is TRUE?

a)

The cost of searching an AVL tree is θ(log n) but that of a binary search tree can be O(n)

b)

The cost of searching an AVL tree is θ(log n) but that of a complete binary tree is θ(n log n)

c)

The cost of searching a binary search tree is O(log n ) but that of an AVL tree is θ(n)

d)

The cost of searching an AVL tree is θ(n log n) but that of a binary search tree is O(n)

7.

Which rotation is required in the given AVL tree?

a)

LL Rotation

b)

RR Rotation

c)

LR Rotation

d)

RL Rotation

8.

What is the balance factor of any node in AVL tree?

a)

Height of right subtree - Height of left subtree

b)

Height of left subtree - Height of right subtree

c)

Level number of right subtree - Level number of left subtree

d)

Level number of left subtree - Level number of right subtree

9.
A tree is composed of ____ connected by edges or lines.
a)
Fruit 
b)
Leaf Node
c)
Root Node
d)
Nodes
10.

There are two types of data structures, they are

a)

Static and dynamic

b)

Fast and slow

c)

Large and small

d)

Ascending and descending

11.

Weighted graph

a)

a graph that has a data value labelled on each edge.

b)

The underlying mathematical principles behind the use of graphs.

c)

An object in a graph. Also know as a node (vertices is the plural).

d)

A join (relationship) between two nodes - sometimes called an edge.

12.

A graph where the relationship between vertices is two way.

a)

Undirected Graph

b)

Directed Graph

c)

Adjacency List

d)

Adjacency Matrix

13.

a data structure that stores a list of nodes with their adjacent nodes.

a)

Undirected Graph

b)

Directed Graph

c)

Adjacency List

d)

Adjacency Matrix

14.

a data structure set up as a two dimensional array or grid that shows where there is an edge between each pair of nodes.

a)

Undirected Graph

b)

Directed Graph

c)

Adjacency List

d)

Adjacency Matrix

15.

Tree

a)

data structure similar to a graph, with no loops.

b)

an object in a graph also known as a vertex

c)

a join of relationship between nodes - also know as an arc

d)

the starting node in a rooted tree structure from which all other nodes branch off./

16.
What would a dynamic data structure entail?
a)
Memory is allocated to the data structure as the program executes.
b)
Memory is allocated to the data structure at compile time.
c)
The size of the structure is fixed
d)
The data structure can also double as TNT
17.

In a dynamic data structure where is the memory allocated from to hold the data structure?

a)

Heap

b)

Cache

c)

Secondary Storage

d)

ROM

e)

Virtual Memory

18.

In terms of data structures, what does mutable mean?

a)

A mutable structure is one which can only have data added to it

b)

A mutable structure is one which is fixed in size

c)

A mutable structure is one which allows data to be added, edited, deleted or moved

19.

What does the term immutable mean?

a)

unable to be changed

b)

unable to speak

c)

can be modified

d)

can be increased in size

20.
Which of these data structures is FIFO
a)
Stack
b)
Queue
c)
Binary Tree
d)
Double linked list
21.

What distinguishes a complete binary tree from a regular binary tree?

a)

A complete binary tree is always balanced in height.

b)

A complete binary tree is fully filled at all levels except possibly the last, while a regular binary tree can have varying structures.

c)

A complete binary tree can have any number of children per node.

d)

A complete binary tree has nodes only on the left side.

22.

Explain the concept of a binary search tree.

a)

A binary search tree is a data structure that only allows duplicate values in the left child.

b)

A binary search tree is a linear data structure where each node can have any number of children.

c)

A binary search tree is a type of graph where nodes are connected in a circular manner.

d)

A binary search tree is a hierarchical data structure where each node has at most two children, with the left child containing values less than the node and the right child containing values greater.

23.

What is a heap in the context of trees?

a)

A heap is a database management system used for storing large datasets.

b)

A heap is a tree-based data structure that satisfies the heap property, allowing efficient access to the maximum or minimum element.

c)

A heap is a type of graph that represents relationships between nodes.

d)

A heap is a linear data structure that stores elements in a sorted order.

24.

Define the term 'root' in a tree structure.

a)

The root is any node in a tree structure.

b)

The root is the node with the highest value in a tree structure.

c)

The root is the topmost node in a tree structure.

d)

The root is the last node in a tree structure.

25.

What is the degree of a node?

a)

The degree of a node is the total number of nodes in the graph.

b)

The degree of a node is the number of edges connected to it.

c)

The degree of a node is the average distance to other nodes.

d)

The degree of a node is its value in the graph.

26.

Differentiate between terminal nodes and non-terminal nodes.

a)

Both terminal and non-terminal nodes are leaf nodes.

b)

Terminal nodes are always at the top of a tree; non-terminal nodes are at the bottom.

c)

Terminal nodes are leaf nodes with no children; non-terminal nodes are internal nodes with children.

d)

Terminal nodes can have children; non-terminal nodes cannot.

27.

What are siblings in a tree?

a)

Nodes that share the same parent in a tree.

b)

Nodes that are at the same level in a tree.

c)

Nodes that are connected by a direct edge in a tree.

d)

Nodes that share the same grandparent in a tree.

28.

Define the level of a node in a tree.

a)

The level of a node is its value in the tree.

b)

The level of a node is the depth of the tree.

c)

The level of a node is the number of edges from the root to that node.

d)

The level of a node is the total number of nodes in the tree.

29.

Explain what a path is in the context of trees.

a)

A path is the total number of nodes in a tree.

b)

A path is a single node in a tree.

c)

A path is a method for balancing trees.

d)

A path in trees is a sequence of nodes connected by edges, representing a route from one node to another.

30.

What is the depth of a node?

a)

The depth of a node is the total number of nodes from the root to that node.

b)

The depth of a node is the number of edges from the root to that node.

c)

The depth of a node is the height of the tree minus the level of that node.

d)

The depth of a node is the number of children that node has.

31.

Who is the parent node of a given node?

a)

The node that is directly connected and one level higher in the hierarchy.

b)

The node that is the lowest in the hierarchy.

c)

The node that is not connected to any other nodes.

d)

The node that is directly connected and one level lower in the hierarchy.

32.

What are ancestors of a node?

a)

The root node of the tree.

b)

All nodes in the tree structure.

c)

Nodes that are on the path from a node to the root in a tree structure.

d)

Nodes that are only leaves in the tree.

33.

What is the height of a tree?

a)

The height of a tree is the number of edges on the longest path from the root to a leaf.

b)

The height of a tree is the total number of nodes in the tree.

c)

The height of a tree is the number of levels in the tree.

d)

The height of a tree is the maximum degree of any node in the tree.

34.

What is the purpose of a traversal in a tree?

a)

A traversal is used to visit all the nodes in a tree in a specific order.

b)

A traversal is used to delete nodes from a tree.

c)

A traversal is used to create a new tree structure.

d)

A traversal is used to find the height of a tree.

35.

In a full binary tree if number of internal nodes is I, then number of leaves L are?



a)

a) L = 2*I

b)

b) L = I + 1

c)

c) L = I – 1

d)

d) L = 2*I – 1

36.

. Construct a binary tree by using postorder and inorder sequences given below.
Inorder: N, M, P, O, Q
Postorder: N, P, Q, O, M

a)

b)

c)

d)

37.

What is the difference between a binary tree and a binary search tree?

a)

A binary tree can have any number of children per node; a binary search tree has at most two children with specific ordering.

b)

A binary tree is always balanced; a binary search tree can be unbalanced.

c)

A binary tree allows duplicate values; a binary search tree does not.

d)

A binary tree is a type of graph; a binary search tree is a linear data structure.

38.

What is a subtree?

a)

A subtree is a tree consisting of a node and all its descendants.

b)

A subtree is a tree that has no nodes.

c)

A subtree is a part of a tree that contains only leaf nodes.

d)

A subtree is a tree that is disconnected from the main tree.

39.

What is the purpose of a binary tree traversal algorithm?

a)

To rearrange the nodes in a binary tree.

b)

To visit all the nodes in a binary tree in a specific order.

c)

To find the maximum value in a binary tree.

d)

To delete nodes from a binary tree.

40.

Construct a binary search tree by using postorder sequence given below.
Postorder: 2, 4, 3, 7, 9, 8, 5.

a)

b)

c)

d)

41.

For the given graph(G), which of the following statements is true?

a)

G is a complete graph

b)

G is not a connected graph

c)

The vertex connectivity of the graph is 2

d)

The edge connectivity of the graph is 1

42.

What is the number of edges present in a complete graph having n vertices?



a)

a) (n*(n+1))/2

b)

b) (n*(n-1))/2

c)

c) n

d)

d) Information given is insufficient

43.

Which of the following properties does a simple graph not hold?

a)

Must be connected

b)

Must be unweighted

c)

Must have no loops or multiple edges

d)

Must have no multiple edges

44.

Which of the following is true?

a)

a) A graph may contain no edges and many vertices

b)

b) A graph may contain many edges and no vertices

c)

c) A graph may contain no edges and no vertices

d)

d) A graph may contain no vertices and many edges

45.

For a given graph G having v vertices and e edges which is connected and has no cycles, which of the following statements is true?

a)

a) v=e

b)

b) v = e+1

c)

c) v + 1 = e

d)

d) v = e-1

46.

The degree of any vertex of graph is .... ?

a)

The number of edges incident with vertex

b)

Number of vertex in a graph

c)

Number of vertices adjacent to that vertex

d)

Number of edges in a graph

47.

Which of the above graphs is/are NOT planar?

a)

G1

b)

G2

c)

G3

d)

G4

48.

What will be the number of edges in a complete bipartite graph Km,n

a)

m+n

b)

m.n

c)

Data Insufficient

49.

A graph is a collection of

a)

Row and columns

b)

Vertices and edges

c)

Equations

d)

Childrens and parents

50.

Determine whether the graph is a bipartite.

a)

Yes, the graph is a bipartite.

b)

No, the graph is not a bipartite.

51.

Find a length of a shortest path between a -- g

a)

7

b)

10

c)

5

d)

4

e)

9

52.
Circuits start and stop at 
a)
same vertex
b)
different vertices
53.

Is the graph is planar or not?

a)

Planar

b)

Not planar

54.

Which of the following graphs is not a regular graph?

a)

Isolated Graph

b)

Cycle

c)

Complete Graph

d)

Wheel

55.

Which type of graph has all the vertex of the first set connected to all the vertex of the second set?

a)

Regular Graph

b)

Wheel

c)

Bipartite Graph

d)

Complete Bipartite Graph

56.

The degree of any vertex of graph is .... ?

a)

The number of edges incident with vertex

b)

Number of vertex in a graph

c)

Number of vertices adjacent to that vertex

d)

Number of edges in a graph

57.

Which of the following is a correct representation of a complete bipartite graph?

a)

K2,2

b)

K4

c)

K5

d)

C3

58.

Vertex

a)

a line connecting two vertices

b)

a point

c)

an edge

d)

an edge that starts and ends at the same vertex

59.

A loop is when

a)

there is a path going from a vertex back to itself

b)

An edge that starts and ends at the same vertex

c)

if it were removed, the graph would be disconnected

d)

connects two vertices to each other

60.

A path is

a)

an edge that starts and ends at the same vertex

b)

a connection between two vertices

c)

a series of consecutive edges in which no edge is repeated

d)

a complete graph

61.

A graph is connected if

a)

Each vertex can reach any other vertex

b)

each vertex is adjacent to every other vertex

c)

All the vertices are odd

d)

the length of all the edges are equal

62.

Which of the following statements is NOT true?

a)

The points in a graph are called vertices.

b)

There are only three types of graphs in discrete mathematics.

c)

The lines between points in a graph are called edges.

d)

A graph is a collection of points and lines between those points.

63.

What is the difference between a directed and an undirected graph?

a)

A directed graph uses arrows to indicate one-way relationships, but an undirected graph does not.

b)

A directed graph can contain weights on the edges, but an undirected graph cannot.

c)

A directed graph can contain multiple edges and loops, but an undirected graph cannot.

d)

There is no difference between directed and undirected graphs.

64.

Which type of traversal of binary search tree outputs the value in sorted order?

a)

Pre-order

b)

Post-order

c)

In-Order

d)

None

65.

Which of the following sequences denotes the post order traversal sequence of the tree?

a)

f e g c d b a

b)

g c b d a f e

c)

g c d b f e a

d)

f e d g c b a

66.

In a tree data structure, any nodes that have no children (where the tree ends) are called ___

a)

boundary nodes

b)

leaf nodes

c)

orphan nodes

d)

terminal nodes

67.

Which data structure is used for data that links arbitrarily, and includes things like loops?

a)

binary trees

b)

circular trees

c)

graphs

d)

dynamic linked stacks

68.
A tree is composed of ____ connected by edges or lines.
a)
Fruit 
b)
Leaf Node
c)
Root Node
d)
Nodes
69.
A Kind of tree where every node in a tree can have at most two children.
a)
Binary Tree
b)
Binary Expression Tree
c)
Tree
d)
Binary Search Tree
70.

What is the value of the ROOT node in this Tree?

a)

35

b)

24

c)

42

d)

20

71.

Root

a)

data structure similar to a graph, with no loops.

b)

an object in a graph also known as a vertex

c)

a join of relationship between nodes - also know as an arc

d)

the starting node in a rooted tree structure from which all other nodes branch off./

72.

Tree

a)

data structure similar to a graph, with no loops.

b)

an object in a graph also known as a vertex

c)

a join of relationship between nodes - also know as an arc

d)

the starting node in a rooted tree structure from which all other nodes branch off./

73.

How many leaf are there in the tree?

a)

1

b)

3

c)

4

d)

7

74.

What are the 3 depth traversals for a tree data structure?

a)

Pre-, In- and Post-order

b)

Pro-, In- and Past-order

c)

Pre-, Out- and Post-order

d)

Pre-, In- and New-order

75.
Root has more left descendants than the right descendants or vice versa.
a)
Balanced Tree
b)
Perfect Tree
c)
Right Tree
d)
Unbalanced Tree
76.

Select the correct tree traversal method for the following description:

Root - Left Subtree - Right Subtree

a)

Pre-Order

b)

In-Order

c)

Post-Order

77.

Select the correct tree traversal method for the following description:

Left Subtree - Root - Right Subtree

a)

Pre-Order

b)

In-Order

c)

Post-Order

78.

Select the correct tree traversal method for the following description:

Left Subtree - Right Subtree - Root

a)

Pre-Order

b)

In-Order

c)

Post-Order

79.
Which of these sorting methods uses "divide and conquer"?
a)
Bubble Sort
b)
Quick Sort
c)
Cocktail Sort
d)
Selection Sort
80.
How do you measure of the time complexity?
a)
Big-O notation
b)
Big-N notation
c)
N notation
d)
Small-O notation
e)
Small-N notation
81.
What does the big-O notation show?
a)
The effectiveness of an algorithm
b)
The amount of time required to solve a particular problem
c)
How difficult a problem is to solve
d)
How many lines of code are required to solve a problem
e)
How quickly a solution can be developed
82.
The Depth First Search traversal of a graph will result into ______________.
a)
Linked List
b)
Queue
c)
Stack
d)
Spanning Tree
83.
Quick sort running time depends on the selection of ____________.
a)
Size of array
b)
Pivot element
c)
Sequence of values
d)
None of the above
84.

Is the graph is planar or not?

a)

Planar

b)

Not planar

85.

List item used in graph

a)

node, junction, branch

b)

root, leaf, flower

c)

child, parent, siblings

d)

edge, vertices, degree