• Home
  • University of the People
  • Data Structures (proctored course) CS 3303
  • Understanding Binary Trees

Understanding Binary Trees

What is a Binary Tree? A binary tree is a type of data structure that consists of multiple tree nodes. Each of these nodes should have at most 2 child nodes linked to it. The top-most node is referred to as the root node for this tree. Child nodes contain references to their parent nodes which in turn helps in easier access of data. A node with no children in the binary tree is referred to as a leaf node. A tree consists of other subtrees which are direct child nodes to the root node. In the following example, node 3 is the root for the first subtree and 10 is the second. The depth of a node is the number of edges present in path from the root node of a tree to that node (GeekforGeeks, n.d). The height of a node is the number of edges present ir the longest path connecting that node to a leaf node (GeekforGeeks, n.d). Below is a graphical representation of a binary tree: (GeekforGeeks, n.d) Binary Tree Implementation Each node of a binary-tree contains 3 pieces of information that will be used to refer and access child nodes. These are: *left reference, the data itself, *right reference. Using a pointer, we can implement a pointer. The pointer points at a root node. Moving through the tree is represented by the pointer, where it gets reference to the next node to point to from the current node. References GeeksforGeeks. (n.d.). Binary Search Tree. Retrieved September 26, 2022, from https://www.geeksforgeeks.org/binary-search-tree-data-structure/