Site icon Study Algorithms

Structure of Binary Trees

We learned about trees and binary trees in the following posts:-

Now let us try to define the structure of the binary tree. For simplicity, assume that the data of the nodes are integers. One way to represent a node (which contains the data) is to have two links which points to the left and right children along with data fields as shown below:

// Defining the basic structure for a binary tree node

struct binaryTreeNode {
    int data;
    struct binaryTreeNode * left;
    struct binaryTreeNode * right;
};

Please note that in trees, the default flow is from parent to children and showing directed branches is not compulsory. For our discussion, we assume both the representations are same.

Operations on Binary Trees

Basic Operations

Auxiliary Operations

Applications of Binary Trees

Following are some of the applications where Binary Trees play an important role –

Exit mobile version