Binary trees

Binary trees are an important data structure in computer science. They are often used for search, priority queues, and databases. They are efficient because they are easy to traverse in a concurrent fashion. Go has great concurrency primitives (which we'll discuss in Chapter 3, Understanding Concurrency) that allow us to do this in a simple manner. Being able to use goroutines and channels to walk a binary tree can help speed up how we traverse a grouping of hierarchical data. A balanced binary tree can be seen in the following diagram:

A couple of special binary trees are as follows:

  • Full binary tree: Every node sans the leaf nodes has 2 child nodes.
  • Complete binary tree: A tree that is completely filled, sans the bottom layer. The bottom layer must be filled from left to right.
  • Perfect binary tree: A complete binary tree in which all the nodes have two children and all the leaves of the tree are at the same level.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.82.244