Unit 6: Shortest Paths & Trees - Practice Quiz

MTH136 — Discrete Structures 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 In a weighted graph, what does the weight assigned to an edge typically represent?

labelled and weighted graph Easy
A. The direction of the edge only
B. The color assigned to the edge
C. The number of vertices in the graph
D. A numerical value such as cost, distance, or time

2 A graph in which each vertex or edge is assigned a name or label is called a:

labelled and weighted graph Easy
A. Complete graph
B. Null graph
C. Regular graph
D. Labelled graph

3 The shortest path between two vertices in a weighted graph is the path with the:

shortest path in weighted graphs Easy
A. Maximum total edge weight
B. Minimum total edge weight
C. Minimum number of vertices
D. Maximum number of edges

4 In an unweighted graph, the shortest path between two vertices is measured by the:

shortest path in weighted graphs Easy
A. Product of edge weights
B. Sum of vertex labels
C. Number of disconnected components
D. Number of edges in the path

5 Dijkstra's algorithm is used to find the shortest path from:

Dijkstra's algorithm to find shortest path Easy
A. The vertex with the highest degree only
B. A single source vertex to all other vertices
C. Every vertex to every other vertex simultaneously in a single pass
D. Only between two adjacent vertices

6 A key limitation of Dijkstra's algorithm is that it does not work correctly with:

Dijkstra's algorithm to find shortest path Easy
A. Negative edge weights
B. Undirected graphs
C. Weighted graphs
D. Connected graphs

7 At each step, Dijkstra's algorithm selects the unvisited vertex with the:

Dijkstra's algorithm to find shortest path Easy
A. Highest vertex label
B. Smallest known distance from the source
C. Most number of neighbors
D. Largest known distance from the source

8 A tree is best defined as a connected graph that:

introduction to tree Easy
A. Has multiple disconnected parts
B. Contains exactly one cycle
C. Has no edges
D. Contains no cycles

9 A tree with vertices always has exactly how many edges?

introduction to tree Easy
A.
B.
C.
D.

10 How many paths exist between any two distinct vertices in a tree?

introduction to tree Easy
A. At least three
B. Exactly one
C. Exactly two
D. None

11 In a rooted tree, the topmost vertex from which the tree originates is called the:

rooted tree Easy
A. Root
B. Leaf
C. Edge
D. Sibling

12 In a rooted tree, a vertex that has no children is known as a:

rooted tree Easy
A. Root node
B. Internal node
C. Leaf node
D. Parent node

13 A binary tree is a rooted tree in which every node has at most:

binary tree Easy
A. Three children
B. One child
C. Two children
D. Four children

14 What is the maximum number of nodes at level of a binary tree, taking the root as level ?

binary tree Easy
A.
B.
C.
D.

15 A spanning tree of a connected graph is a subgraph that:

spanning tree Easy
A. Includes only some of the vertices of
B. Includes all edges of the original graph
C. Includes all vertices of and is a tree
D. Contains at least one cycle among its vertices

16 A spanning tree of a connected graph with vertices contains exactly how many edges?

spanning tree Easy
A.
B.
C.
D.

17 A minimum spanning tree (MST) of a weighted graph is the spanning tree with the:

minimum spanning tree Easy
A. Minimum number of vertices
B. Minimum total edge weight
C. Maximum number of edges
D. Maximum total edge weight

18 Kruskal's algorithm builds a minimum spanning tree by considering edges in order of:

Kruskal and Prims algorithms to find minimum spanning tree Easy
A. Random selection
B. Vertex label
C. Increasing weight
D. Decreasing weight

19 While adding edges, Kruskal's algorithm avoids selecting an edge that would:

Kruskal and Prims algorithms to find minimum spanning tree Easy
A. Form a cycle
B. Increase the number of vertices
C. Reduce the total weight
D. Connect two vertices

20 Prim's algorithm builds the minimum spanning tree by:

Kruskal and Prims algorithms to find minimum spanning tree Easy
A. Removing the heaviest edges from the graph
B. Growing the tree one vertex at a time from a starting vertex
C. Selecting vertices with the highest degree first
D. Sorting all edges globally and adding the smallest ones first regardless of connectivity

21 In a weighted graph, the sum of the weights of all edges in a path is called the:

labelled and weighted graph Medium
A. Edge count
B. Path length or path weight
C. Graph diameter
D. Vertex degree

22 A weighted graph has edges with weights that represent distances. If an edge between vertices and has weight and no edge exists between and , which statement is correct?

labelled and weighted graph Medium
A. The distance equals
B. The edge has weight by default
C. The distance is considered until a path is found
D. The distance equals

23 Which property must hold for a shortest path between two vertices in a weighted graph with non-negative weights?

shortest path in weighted graphs Medium
A. It always has the fewest number of edges
B. It must always pass through the vertex of highest degree
C. It must include every edge of minimum weight
D. Every subpath of a shortest path is also a shortest path

24 A shortest path that minimizes the number of edges rather than total weight would be found by treating the graph as:

shortest path in weighted graphs Medium
A. A weighted graph and using Dijkstra
B. A complete graph and using Prim's algorithm
C. An unweighted graph and using BFS
D. A tree and using DFS

25 Dijkstra's algorithm fails to give correct results when the graph contains:

Dijkstra's algorithm to find shortest path Medium
A. Vertices with high degree
B. Cycles of positive weight
C. More than one path between vertices
D. Negative weight edges

26 In Dijkstra's algorithm, once a vertex is marked as finalized (added to the set of visited vertices), its shortest distance:

Dijkstra's algorithm to find shortest path Medium
A. Is set to infinity
B. May decrease later
C. May increase later
D. Will never change again

27 Consider a graph with edges , , . Using Dijkstra from , the shortest distance to is:

Dijkstra's algorithm to find shortest path Medium
A.
B.
C.
D.

28 Using a binary min-heap (priority queue), the time complexity of Dijkstra's algorithm for a graph with vertices and edges is:

Dijkstra's algorithm to find shortest path Medium
A.
B.
C.
D.

29 A connected graph with vertices is a tree if and only if it has exactly:

introduction to tree Medium
A. edges
B. edges
C. edges
D. edges

30 Which of the following is NOT necessarily true for a tree?

introduction to tree Medium
A. It contains at least one cycle
B. There is a unique path between any two vertices
C. Removing any edge disconnects it
D. It is connected

31 In a rooted tree, a vertex with no children is called a:

rooted tree Medium
A. Leaf (or terminal node)
B. Sibling node
C. Internal node
D. Root node

32 In a rooted tree, the length of the path from the root to a given node is called that node's:

rooted tree Medium
A. Height
B. Degree
C. Width
D. Depth (or level)

33 The maximum number of nodes in a binary tree of height (root at height ) is:

binary tree Medium
A.
B.
C.
D.

34 A binary tree with internal nodes, where every internal node has exactly two children (a full binary tree), has how many leaf nodes?

binary tree Medium
A.
B.
C.
D.

35 How many distinct binary trees can be formed using unlabelled nodes?

binary tree Medium
A.
B.
C.
D.

36 A spanning tree of a connected graph with vertices always contains:

spanning tree Medium
A. Exactly edges
B. All edges of the graph
C. Exactly edges
D. At least one cycle

37 By Cayley's formula, the number of distinct spanning trees of a complete graph is:

spanning tree Medium
A.
B.
C.
D.

38 If all edge weights in a connected graph are distinct, then the minimum spanning tree is:

minimum spanning tree Medium
A. Never unique
B. Always the same as any spanning tree
C. Unique
D. Undefined

39 Kruskal's algorithm selects edges in increasing order of weight while avoiding cycles. Which data structure efficiently detects cycles during this process?

Kruskal and Prims algorithms to find minimum spanning tree Medium
A. Min-heap only
B. Union-Find (disjoint set)
C. Adjacency matrix
D. Stack

40 A key difference between Prim's and Kruskal's algorithms is that Prim's algorithm:

Kruskal and Prims algorithms to find minimum spanning tree Medium
A. Can produce a forest during execution
B. Sorts all edges before starting
C. Only works on directed graphs
D. Grows a single connected tree from a starting vertex

41 Dijkstra's algorithm may produce incorrect shortest-path results when a graph contains which of the following?

Dijkstra's algorithm to find shortest path Hard
A. A large number of vertices
B. Self-loops with positive weight
C. Parallel edges with equal weights
D. Negative weight edges

42 Using a binary min-heap as the priority queue, the time complexity of Dijkstra's algorithm on a graph with vertices and edges is:

Dijkstra's algorithm to find shortest path Hard
A.
B.
C.
D.

43 If all edge weights in a connected weighted graph are distinct, which statement about its minimum spanning tree (MST) is true?

minimum spanning tree Hard
A. There may be several MSTs of equal weight
B. The MST is a Hamiltonian path
C. The MST is unique
D. The MST always contains the two heaviest edges

44 By Cayley's formula, the number of distinct spanning trees of the complete graph is:

spanning tree Hard
A.
B.
C.
D.

45 The Union-Find data structure with union by rank and path compression is used in Kruskal's algorithm primarily to:

Kruskal and Prims algorithms to find minimum spanning tree Hard
A. Compute shortest distances between components
B. Sort the edges by weight faster
C. Store the final MST edges in order
D. Efficiently detect whether adding an edge forms a cycle

46 A binary tree has internal nodes each with exactly two children (a full binary tree). How many leaf nodes does it have?

binary tree Hard
A.
B.
C.
D.

47 Prim's algorithm grows the MST by repeatedly selecting the minimum-weight edge that:

Prims algorithm to find minimum spanning tree Hard
A. Has not yet been examined regardless of endpoints
B. Crosses the cut between the tree and the remaining vertices
C. Completes a cycle within the current tree
D. Connects the two most distant vertices

48 A weighted graph has vertices. Which representation gives time to query the weight of a specific edge ?

labelled and weighted graph Hard
A. Edge list
B. Adjacency list
C. Incidence matrix
D. Adjacency matrix

49 Consider a connected weighted graph. If an edge is the unique maximum-weight edge on some cycle, which property guarantees is excluded from the MST?

minimum spanning tree Hard
A. The pigeonhole principle
B. The handshake lemma
C. The cut property
D. The cycle property

50 In a weighted graph where every edge weight is multiplied by a positive constant , the shortest path between any two vertices:

shortest path in weighted graphs Hard
A. Becomes the longest path
B. Is unaffected in both edges and total cost
C. May change to a completely different route
D. Remains the same set of edges, with total cost scaled by

51 In a rooted tree with nodes, what is the sum of the number of children over all nodes?

rooted tree Hard
A.
B.
C.
D.

52 During Dijkstra's execution, at the moment a vertex is extracted from the priority queue, which invariant holds?

Dijkstra's algorithm to find shortest path Hard
A. Every neighbor of is already finalized
B. The distance label of equals its true shortest distance from the source
C. must be adjacent to the source
D. has the largest distance among all vertices

53 For a dense graph with edges, which MST algorithm/implementation is typically most efficient?

Kruskal and Prims algorithms to find minimum spanning tree Hard
A. Kruskal's with edge sorting in
B. Prim's with a binary heap in
C. Prim's with an adjacency matrix in
D. Repeated Dijkstra from every vertex

54 What is the maximum number of nodes in a binary tree of height (where a single node has height )?

binary tree Hard
A.
B.
C.
D.

55 A connected graph has vertices and edges. The number of edges that must be removed to obtain a spanning tree is:

spanning tree Hard
A.
B.
C.
D.

56 Which statement correctly relates the MST and the shortest-path tree (SPT) rooted at a vertex in a weighted graph?

minimum spanning tree Hard
A. The SPT always has smaller total weight than the MST
B. They can be different trees for the same graph
C. The MST is always a subtree of the SPT
D. They are always identical

57 If a weighted directed graph contains a negative-weight cycle reachable from the source, the shortest-path problem:

shortest path in weighted graphs Hard
A. Is undefined because distances can decrease without bound
B. Can be solved correctly by Dijkstra's algorithm
C. Has shortest distances equal to zero
D. Always has a unique finite solution

58 Both Kruskal's and Prim's algorithms are greedy and correct because they rely on which fundamental principle?

Kruskal and Prims algorithms to find minimum spanning tree Hard
A. Optimal substructure of longest paths
B. The cut property guarantees the minimum crossing edge is safe to add
C. The matrix-tree theorem
D. Dynamic programming over subsets

59 In a complete -ary rooted tree with internal nodes, the total number of nodes is:

rooted tree Hard
A.
B.
C.
D.

60 In a weighted graph, if a unique edge has strictly the smallest weight, then this edge:

labelled and weighted graph Hard
A. Must form a cycle in the MST
B. May be excluded from some MST
C. Is always the root of the spanning tree
D. Belongs to every minimum spanning tree