Free Online Flashcard Deck

10 Trees and Graph Algorithms Free Online FlashCards

Study 10 Trees and Graph Algorithms with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a tree?

Back

A tree is a connected, acyclic undirected graph.

02
Front

How many edges does a tree with nn vertices have?

Back

A tree with nn vertices has exactly n−1n-1 edges.

03
Front

What is a leaf in a tree?

Back

A leaf is a vertex of degree 1. Every tree with at least two vertices has at least two leaves.

04
Front

What is a spanning tree?

Back

A spanning tree contains every vertex of the graph and is itself a tree.

05
Front

How does Kruskal's algorithm build an MST?

Back

Kruskal's algorithm sorts edges by increasing weight and adds an edge when it joins two previously disconnected components.

06
Front

How does Prim's algorithm build an MST?

Back

Prim's algorithm starts with one vertex and repeatedly adds the minimum-weight edge connecting the current tree to a vertex outside it.

07
Front

In a rooted tree, what is a vertex's parent?

Back

The parent of a vertex is the next vertex on its path toward the root.

08
Front

What is the height of a rooted tree?

Back

The height of a rooted tree is the maximum depth of any vertex.

09
Front

What data structure does BFS use, and how does it explore?

Back

BFS uses a queue and visits vertices level by level.

10
Front

How does DFS explore a graph?

Back

DFS follows one branch as far as possible before backtracking; it can use recursion or an explicit stack.

11
Front

What is inorder traversal for a binary tree?

Back

Inorder traversal processes the left subtree, then the vertex, then the right subtree.

12
Front

What is the adjacency-list runtime of BFS and DFS?

Back

For adjacency lists, BFS and DFS run in O(∣V∣+∣E∣)O(|V|+|E|) time.