Binary trees are fairly straightforward to explain.
Computer science trees are made up of two types of parts: nodes (you just need to know that nodes hold data) and edges (think of these like pointers).
Each node can point (with edges) at another node, which is then called its child node.
(To that child node, then, the original node is its parent node.
)The first node in a tree is called the root node, which never has any other nodes’ edges pointing towards it.
A node that doesn’t point to any other nodes, i.
a node with no edges, is called a leaf.
The root node is at the top of the tree, and its children are beneath it, so to visualize a computer science tree, just imagine an upside-down biological tree.
Imagine this tree, but flipped!.Photo by Lionello DelPiccolo on UnsplashEvery node can point to multiple other nodes.
This trait (which I like to refer to as “multi-point-edge-iality”) is the most distinguishing trait of trees, because it means the data isn’t accessed in a single, linear fashion.
Thus, trees are a non-linear data structure.
A binary tree is a type of tree.
It has all the same characteristics as a standard tree, with one specification: each node can point to a maximum of two child nodes.
This additional constraint makes binary trees incredibly useful for programming methods like search (looking through the tree to find the data you want).
Binary trees are perfectly suited for the task of binary search (making the tree a binary search tree), which is simpler than it sounds.
It consists of the following steps:Check the root node’s data.
If it’s what you’re looking for, great!.If not, see if the root node’s data is greater than or less than your target.
If it’s greater than your target, go to step #2.
If it’s less than your target, go to step #3.
Go to the left child node.
(The root node’s edges are designated left and right; the left edge points you to the left child node.
) Treat this left child node as your new root node, and go back to step #1.
Go to the right child node.
Treat this right child node as your new root node, and go back to step #1.
Photo by Micah Hallahan on UnsplashThe steps above assume, of course, that the tree’s nodes contain data in the form of numbers.
It’s possible to store words-based data (called strings in the programming world) in trees as well.
In that case, the sorting would be based on alphabetical order instead of numerically ascending.
So what does any of this have to do with Daenerys?!.Great question!.To start off, let’s take what we now know about trees and apply it to the human perspective.
The root node is the underlying guiding question a person has, the one they use to build their perception of the world and people around them.
The edges, rather than having left and right designators like a binary search tree’s would, are instead each associated with a single possible answer to that question.
An edge that is marked with a clear, action-based answer will then point to a leaf node, whose data is simply the conclusive decision that the person should make.
An edge that is marked with a “needs further investigation” note will point to another node with another question, which has its own edges pointing to further nodes with answers or more questions.
It’s not a stretch to say that Daenerys’s unyielding “for me or against me” mentality would be best described as a binary tree with three total nodes: the root node with her question, the two child nodes with her possible choices, and their associated edges with the answers guiding to those choices.
The root node’s data asks the question, “Is this person unconditionally supportive of my claim, or do they threaten my right to the throne?”One edge represents the answer, “They unconditionally support my claim; they are for me.
” It points to a conclusive decision of acceptance and compassion, both of which Daenerys has demonstrated multiple times throughout her story.
The other edge represents the answer, “They threaten my right to the throne.
” It points to a conclusive decision of killing them (or likely, in Daenerys’s mind, “executing” them, even in the absence of a trial), likely with dragonfire.
Daenerys has killed multiple dissidents and evidently believes they do not deserve her mercy or compassion.
A more mature tree model would not be so starkly black-and-white.
It would not be restricted to only two choices, and only two possible outcomes (and thus could not be represented by a binary tree).
More adept players of the game of thrones (Margaery Tyrell, Olenna Tyrell, Petyr Baelish, and Varys come to mind) would be better represented by a complex tree with lots and lots of nodes.
Hopefully this blog post illuminated your understanding of Daenerys Targaryen, tree data structures, or both!.Please leave your thoughts in the comments below.
References & Further ReadingGame of Thrones, HBO“How to Not Be Stumped By Trees”, Vaidehi Joshi“Leaf It Up To Binary Trees”, Vaidehi Joshi.