Free Practice Quiz Question List

10 Trees and Graph Algorithms Online Quiz Questions

Use this free practice quiz with 20 questions to review 10 Trees and Graph Algorithms, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

Which statement correctly describes an adjacency matrix for a graph?

  1. A

    It uses O(|V|+|E|) space and tests an edge in O(|V|) time.

  2. B

    It uses O(|V|^2) space and tests whether a specified edge exists in O(1) time.

  3. C

    It uses O(|E|) space and tests an edge in O(|E|) time.

  4. D

    It uses O(|V|) space and tests an edge in O(log |V|) time.

02
True or false
1 point

Adding any new edge to a tree creates exactly one cycle.

  1. A

    True

  2. B

    False

03
Written response
1 point

What is the term for the vertex immediately next to a given vertex on the path toward the root?

04
Fill in the blank
1 point

Breadth-first search uses a to process vertices in level order.

05
Choose one
1 point

Which description best defines a spanning tree of a connected graph?

  1. A

    A subgraph containing only vertices of odd degree

  2. B

    A subgraph containing every vertex and forming a tree

  3. C

    A subgraph containing every edge of the original graph

  4. D

    A cycle with minimum total edge weight

06
Choose all
1 point

A rooted tree has root r with children a and b; a has children c and d; b has child e. Select all statements that are true.

  1. A

    c and d are siblings.

  2. B

    e is a child of b.

  3. C

    a and b are siblings of c.

  4. D

    r is an ancestor of c.

07
Written response
1 point

In a rooted tree, r is the root; r has children a and b; a has children c and d; and b has child e. What is the height of the tree?

08
Choose one
1 point

Which action is characteristic of Kruskal's minimum-spanning-tree algorithm?

  1. A

    It repeatedly chooses the vertex with the greatest degree.

  2. B

    It starts from one vertex and always expands through that vertex's cheapest incident edge.

  3. C

    It sorts edges by increasing weight and adds an edge when it connects different components.

  4. D

    It performs BFS and records the first edge used to reach each vertex.

09
True or false
1 point

A directed cycle prevents a topological ordering from existing.

  1. A

    True

  2. B

    False

10
Choose all
1 point

Which of the following are applications of decision trees? Select all correct choices.

  1. A

    Classification

  2. B

    Diagnosis

  3. C

    Game strategies

  4. D

    Program control flow

11
Open ended
1 point

Explain the main operational difference between breadth-first search and depth-first search. Include the usual adjacency-list running time of each and one task for which either method is especially suitable.

12
Choose one
1 point

Which test correctly determines whether a connected undirected graph with nn vertices is a tree?

  1. A

    Check only whether every vertex has degree at most two.

  2. B

    Check whether the graph has at least n edges.

  3. C

    Check that the graph is connected, has n-1 edges, and contains no cycle.

  4. D

    Check whether a BFS visits vertices in alphabetical order.

13
Choose one
1 point

Which condition defines a binary tree?

  1. A

    Every vertex has exactly two children.

  2. B

    Every vertex has at most two children.

  3. C

    Every leaf has exactly two parents.

  4. D

    All vertices must lie at the same depth.

14
Choose one
1 point

An undirected graph is known to be a tree with 9 vertices. How many edges must it have?

  1. A

    7

  2. B

    8

  3. C

    9

  4. D

    10

15
True or false
1 point

In an unweighted graph, breadth-first search can find a shortest path from a source vertex to every reachable vertex.

  1. A

    True

  2. B

    False

16
Written response
1 point

Which minimum-spanning-tree algorithm sorts all edges by increasing weight and adds an edge whenever it joins two previously disconnected components?

17
Choose one
1 point

For a graph with vertices A,B,C,DA,B,C,D and edges AB,AC,BC,BD,CDAB, AC, BC, BD, CD, which edge set is a spanning tree?

  1. A

    AB,AC,BCAB, AC, BC

  2. B

    AB,BC,CA,ADAB, BC, CA, AD

  3. C

    AB,AC,BD,CDAB, AC, BD, CD

  4. D

    AB,AC,BC,BD,CDAB, AC, BC, BD, CD

18
Choose one
1 point

In a rooted tree, rr is the root, bb is a child of rr, and ee is a child of bb. What is the depth of ee?

  1. A

    0

  2. B

    2

  3. C

    3

  4. D

    4

19
Written response
1 point

An unweighted graph has edges s−as\mathord{-}a, s−bs\mathord{-}b, a−ca\mathord{-}c, b−db\mathord{-}d, c−xc\mathord{-}x, and d−xd\mathord{-}x. What shortest-path distance does BFS assign from ss to xx, measured in edges?

20
Fill in the blank
1 point

During depth-first search of an undirected graph, encountering an already visited neighbor that is not the current vertex's indicates that the graph contains a cycle.