liveBook · Manning

Tree

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

A tree is a connected, acyclic structure of nodes, commonly organized hierarchically through parent-child relationships and optionally around a designated root.

A tree is a graph with exactly one path between any two vertices, so it contains no cycles. Removing an edge from a cycle can turn a graph into a tree. section 4.3

Figure 4.6. In (a), a cycle exists between vertices B, C, and D, so it is not a tree. In (b), the edge connecting C and D has been pruned, so the graph is a tree.

The diagram contrasts a cycle through B, C, and D with the tree formed by removing the edge between C and D. section 4.3

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Defines trees through unique paths and cycles, then distinguishes connected graphs, spanning trees, and minimum spanning trees.
Examples
Uses a cycle among vertices B, C, and D, then removes the edge between C and D to form a tree.
What you can do after
Understand how removing an edge from a cycle can turn a graph into a tree.
How it connects
Connects trees to graphs, cycles, connected graphs, spanning trees, and minimum spanning trees.

Also explained in

Compare how 11 books explain tree →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.