What is a Binary Tree?


Go through my previous post about  What are Trees if you haven’t already read it to completely understand the binary trees.

Binary Trees

In general, tree nodes can have any number of children. In a binary tree, the nodes have no more than two children. Figure 1 has examples of binary trees. Figure 2 isn’t a binary tree because several of its nodes have three children. A node in a binary tree isn’t required to have two children. For example, node b in Figure 1  has only one child. Of course, the leaves of a binary tree have no children.

Figure 1: Binary Tree

Figure 2 : Not a Binary Tree

Every tree has a height, which is defined as the maximum number of nodes that must be visited on any path from the root to a leaf. For instance, the tree in Figure 1 has a height of 3. In turn, the depth of a node is the number of nodes along the path from the root to that node. For instance, node c in Figure 1  has a depth of 1. Also go through How to Find the height of a Binary Tree.

Advertisements
  1. Height of the binary tree! « Encrypt3d

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: