Chapter 5
Chapter 5
Introduction
• A tree data structure is a collection of nodes connected by edges. Each node contains a
value or data which may or may not have a child node. The first node of the tree is called
the root.
• Tree data structure is a specialized data structure to store data in hierarchical manner.
It is used to organize and store data in the computer to be used more effectively. It
consists of a central node, structural nodes, and sub-nodes, which are connected via
edges. We can also say that tree data structure has roots, branches, and leaves connected.
class Node {
public:
int data;
Node* first_child;
Node* second_child;
Node* third_child;
.
.
.
Node* nth_child;
};