Trees and Forests

Description: This quiz covers various concepts related to trees and forests in graph theory.
Number of Questions: 15
Created by:
Tags: trees forests graph theory
Attempted 0/15 Correct 0 Score 0

Which of the following statements is true about a tree?

  1. It is a connected graph.

  2. It has no cycles.

  3. It has a unique path between any two vertices.

  4. All of the above.


Correct Option: D
Explanation:

A tree is a connected graph with no cycles, and it has a unique path between any two vertices.

What is the maximum number of edges in a tree with n vertices?

  1. n-1

  2. n

  3. n+1

  4. 2n-1


Correct Option: A
Explanation:

The maximum number of edges in a tree with n vertices is n-1, as adding one more edge would create a cycle.

Which of the following is a forest?

  1. A graph with no cycles.

  2. A graph with no isolated vertices.

  3. A graph in which every connected component is a tree.

  4. All of the above.


Correct Option: C
Explanation:

A forest is a graph in which every connected component is a tree.

What is the minimum number of edges in a forest with n vertices?

  1. 0

  2. 1

  3. n-1

  4. n


Correct Option: A
Explanation:

The minimum number of edges in a forest with n vertices is 0, as a forest can have isolated vertices.

Which of the following algorithms can be used to find a minimum spanning tree of a weighted graph?

  1. Kruskal's algorithm

  2. Prim's algorithm

  3. Dijkstra's algorithm

  4. Floyd-Warshall algorithm


Correct Option: A
Explanation:

Kruskal's algorithm and Prim's algorithm are both used to find a minimum spanning tree of a weighted graph.

What is the time complexity of Kruskal's algorithm for finding a minimum spanning tree?

  1. O(E log E)

  2. O(E log V)

  3. O(V log V)

  4. O(V^2)


Correct Option: A
Explanation:

The time complexity of Kruskal's algorithm is O(E log E), where E is the number of edges and V is the number of vertices in the graph.

Which of the following is a property of a binary tree?

  1. It has at most two children for each node.

  2. It has a unique path from the root to each node.

  3. It is a complete tree.

  4. All of the above.


Correct Option: D
Explanation:

A binary tree is a tree in which each node has at most two children, and it has a unique path from the root to each node. A complete binary tree is a binary tree in which all levels are completely filled, except possibly the last level.

What is the maximum number of nodes in a complete binary tree of height h?

  1. 2^h

  2. 2^(h+1) - 1

  3. 2^(h+1)

  4. 2^(h+2) - 1


Correct Option: B
Explanation:

The maximum number of nodes in a complete binary tree of height h is 2^(h+1) - 1.

Which of the following is a traversal method for a binary tree?

  1. Inorder traversal

  2. Preorder traversal

  3. Postorder traversal

  4. All of the above.


Correct Option: D
Explanation:

Inorder traversal, preorder traversal, and postorder traversal are all traversal methods for a binary tree.

What is the time complexity of inorder traversal of a binary tree?

  1. O(log V)

  2. O(V)

  3. O(V log V)

  4. O(V^2)


Correct Option: B
Explanation:

The time complexity of inorder traversal of a binary tree is O(V), where V is the number of vertices in the tree.

Which of the following is a type of tree data structure?

  1. Binary search tree

  2. Red-black tree

  3. AVL tree

  4. All of the above.


Correct Option: D
Explanation:

Binary search tree, red-black tree, and AVL tree are all types of tree data structures.

What is the property of a binary search tree?

  1. The left child of a node is always smaller than the node.

  2. The right child of a node is always larger than the node.

  3. Both of the above.

  4. None of the above.


Correct Option: C
Explanation:

In a binary search tree, the left child of a node is always smaller than the node, and the right child of a node is always larger than the node.

Which of the following is a type of forest data structure?

  1. Trie

  2. Suffix tree

  3. Patricia tree

  4. All of the above.


Correct Option: D
Explanation:

Trie, suffix tree, and Patricia tree are all types of forest data structures.

What is the property of a trie?

  1. It is a tree-like data structure.

  2. It is used for storing strings.

  3. It allows for efficient searching and retrieval of strings.

  4. All of the above.


Correct Option: D
Explanation:

A trie is a tree-like data structure that is used for storing strings. It allows for efficient searching and retrieval of strings.

Which of the following is a type of tree decomposition?

  1. Nice tree decomposition

  2. Path decomposition

  3. Treewidth decomposition

  4. All of the above.


Correct Option: D
Explanation:

Nice tree decomposition, path decomposition, and treewidth decomposition are all types of tree decompositions.

- Hide questions