Trees are a type of non-linear data structure, they store and organize data hierarchically.
The Tree Data Structure connects nodes in a parent - child relationship. A great way to think about this data structure is to think of as a family tree.
Above is my family tree. Benny, Pat, Lena and Joseph are my grandparents. Biagio A and Carmela are my parents. Angelina is my sister ( my parents' children). A tree is a collection of Nodes, each node contains data.
The beginning of the tree, or the first node, is called the root node. Tree nodes connect to each other by links( more commonly called edges). Edges manages the relationship between nodes. The last nodes on the tree without any children are called Leaves. A Parent is a node that has a link to a child node. Another thing to note about trees is the height of a tree is the length of the longest path to a leaf. Also, the depth of a node is the length of the path to its root!
I found that Trees are easier to understand compared to other data structures because the ability to compare it to family tree or an actual tree! I hope you enjoyed this high level view of Tree Data Structures!
Top comments (0)