Bifalgorithm post · Brisk · Chapter 1

What makes a rooted tree different from a free tree?

What makes a rooted tree different from a free tree? (Brisk · Chapter 1) — "Rooted trees\n\nNow a rooted tree is the same thing as a free tree, except that we…

Ideas in this flowchart

  • Rooted trees
  • A rooted tree is a free tree with one node elevated as the root.
  • The choice of root determines the resulting rooted-tree hierarchy.
  • Choosing A as the root places A above the other nodes.
  • Choosing C instead produces a different rooted tree.
  • Changing the root does not change the edges of the free tree.
  • Vertical position represents a node’s relation to the root.
  • A node’s altitude shows how many steps it is from the root.
  • Every node has exactly one path to the root.
  • This unique-path property is inherited from free trees.
  • Trees represent part-whole containment hierarchies.
  • A filesystem has a root directory, nested folders, and files with one distinct path from the root.
  • Organizational and military structures arrange roles in ranked hierarchies.
  • The human body can be represented from systems down through organs, tissues, cells, molecules, and atoms.
  • Trees have numerous applications in computer programming.
  • Compilers use parse trees to represent the meaning of code.
  • HTML structures text as a tree-like hierarchy of displayable elements.
  • Chess programs use trees to represent possible moves and responses.
  • Object-oriented designs use inheritance hierarchies of classes.
  • Other than simple sequences, trees are among the most common data structures in computer science.
Feed/

What makes a rooted tree different from a free tree?

Channel

Brisk

1 page

"Rooted trees\n\nNow a rooted tree is the same thing as a free tree, except that we elevate one node to become the root. It turns out this makes all the difference. Suppose we chose A as the root of Figure 5.15. Then we would have the rooted tree in the left half of Figure 5.16. The A vertex has been positioned at the top, and everything else is flowing under it. I think of it as reaching into the free tree, carefully grasping a node, and then lifting up your hand so the rest of the free tree dangles from there. Had we chosen (say) C as the root instead, we would have a different rooted tree, depicted in the right half of the figure. Both of these rooted trees have all the same edges as the free tree did: B is connected to both A and C, F is connected only to A, etc. The only difference is which node is designated the root.\n\nUp to now we’ve said that the spatial positioning on graphs is irrelevant. But this changes a bit with rooted trees. Vertical positioning is our only way of showing which nodes are “above” others, and the word “above” does indeed have meaning here: it means closer to the root. The altitude of a node shows how many steps it is away from the root. In the right rooted tree, nodes B, D, and E are all one step away from the root (C), while node F is three steps away. The key aspect to rooted trees — which is both their greatest advantage and greatest limitation — is that every node has one and only one path to the root. This behavior is inherited from free trees: as we noted, every node has only one path to every other.\n\nTrees have a myriad of applications. Think of the files and folders on your hard drive: at the top is the root of the filesystem (perhaps “/” on Linux/Mac or “C:\\” on Windows) and underneath that are named folders. Each folder can contain files as well as other named folders, and so on down the hierarchy. The result is that each file has one, and only one, distinct path to it from the top of the filesystem. The file can be stored, and later retrieved, in exactly one way. An “org chart” is like this: the CEO is at the top, then underneath her are the VP’s, the Directors, the Managers, and finally the rank-and-file employees. So is a military organization: the Commander in Chief directs generals, who command colonels, who command majors, who command captains, who command lieutenants, who command sergeants, who command privates. The human body is even a rooted tree of sorts: it contains skeletal, cardiovascular, digestive, and other systems, each of which is comprised of organs, then tissues, then cells, molecules, and atoms. In fact, anything that has this sort of part-whole containment hierarchy is just asking to be represented as a tree.\n\nIn computer programming, the applications are too numerous to name. Compilers scan code and build a “parse tree” of its underlying meaning. HTML is a way of structuring plain text into a tree-like hierarchy of displayable elements. AI chess programs build trees representing their possible future moves and their opponent’s probable responses, in order to “see many moves ahead” and evaluate their best options. Object-oriented designs involve “inheritance hierarchies” of classes, each one specialized from a specific other. Etc. Other than a simple sequence (like an array), trees are probably the most common data structure in all of computer science."

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.