Tree Data Structure
As learned in the previous section, lists store data linearly, meaning that nodes have pointers to the next and previous nodes. Trees store data differently, in a hierarchy. A tree node will point to its "child" nodes assuming it has any. If so, it is called a "parent" node. A node that does not have any children is called a "leaf" node. There is also only one node at the top of the tree and it's called the "root" node. The pointers to child nodes are "edges", and a "key" is the value of the node. These terms are given so you can better understand the code in the upcoming sections. There are many ways to implement a tree and the most popular tree types will be covered in the following sections. Instead of basic tree code on this page, this diagram should help illustrate the architecture of a tree.