WorksheetsTrees and Graphs Quiz
Total questions: 10
Worksheet time: 5mins
A tree with n vertices always has:
n edges
n-1 edges
n+1 edges
2n edges
Which traversal method of a binary tree gives nodes in sorted order if the tree is a Binary Search Tree (BST)?
Preorder
Inorder
Postorder
Level order
The maximum number of edges in a simple undirected graph with n vertices is:
n(n-1)/2
n^2
n(n+1)/2
2n
Which of the following is not a self-balancing Binary Search Tree?
AVL Tree
Red-Black Tree
B-Tree
Binary Heap
In a tree, the number of leaf nodes is always equal to:
Number of nodes with degree 2
Number of nodes with degree 1
Total nodes – internal nodes
None of the above
Which algorithm is commonly used to find the shortest path in a weighted graph (with positive weights)?
Prim’s Algorithm
Kruskal’s Algorithm
Dijkstra’s Algorithm
Floyd–Warshall Algorithm
In a complete binary tree, the height is approximately:
O(log n)
O(n)
O(1)
O(n log n)
Which data structure is best suited for implementing Breadth First Search (BFS) in a graph?
Stack
Queue
Priority Queue
Hash Table
A connected graph without cycles is called:
DAG (Directed Acyclic Graph)
Tree
Forest
Complete Graph
Which of the following statements about spanning trees is true?
A spanning tree must contain all vertices and all edges
A spanning tree must contain all vertices and no cycles
A spanning tree may exclude some vertices
A spanning tree must have maximum number of edges
