Member-only story
The next part of my Data Structures series is binary search trees.
A Binary Tree is a data structure where each node can have 0, 1 or 2 nodes. Each child can only have 1 parent.
The benefits of using a binary search tree are the look up times are better than O(n), the tree is ordered and the size is flexible. Trees are useful because you can find data going into a subset of the data instead of searching through every element in the tree. A balanced binary search tree look up times are O(log(n)) for access, search, insert and delete. An unbalanced binary tree search are O(n) for access, search, insert and delete.
In a Binary Tree All nodes on the left side of the tree must hold a value that is smaller than its own node and all nodes on the right side of the tree must hold a value that is larger than it’s own node.
A Perfect Binary tree has all leaf nodes filled in. The nodes either have 0 or 1 children. The lowest level of the tree is filled as well. Number of nodes doubles on every level. The lowest level of the tree will equal to all the nodes above that level plus one. Perfect binary trees make it easier to find data.