Data Structures using C PlusPlus: Chapter 6: Trees

Binary Trees

Definition, concept, explanation with diagram

Questions: 1. Explain the concept of binary trees. 2. Write a short note on ‒ Full binary tree and complete binary tree.

Binary Trees

In the trees, we can have any number of child nodes to a parent node. But if we tout impose some restriction on number of child nodes i.e. if we allow at the most two children nodes then that type of tree is called binary tree. Let us formally define binary trees


Definition of a binary tree:

A binary tree is a finite set of nodes which is either empty or consists of a root and two disjoint binary trees called the left sub‒tree and right sub‒tree.

The binary tree can be as shown below.


 

Full binary tree

A full binary tree is a tree in which every node has zero or two children.


 

Complete binary tree

A complete binary tree is full binary tree in which all leaves are at the same depth.


The total number of nodes in complete binary tree are 2h+1 ‒1 where h is a height of the tree. In above given tree height of tree h is 3. Hence there are

23+1 −1 = 24 −1 = 15 nodes in the tree.

The number of leaf nodes n in a complete binary tree can be found using formula:

n = 2h where n is total number of leaf nodes and h is the height of binary tree.

In above given tree h = 3. Hence total 8 nodes (2h) are leaf nodes.

 

Left and right skewed trees

The tree in which each node is attached as a left child of parent node then it is left skewed tree. The tree in which each node is attached as a right child of parent node then it is called right skewed tree.


 

Review Questions

1. Explain the concept of binary trees.

2. Write a short note on ‒ Full binary tree and complete binary tree.

 

Data Structures using C PlusPlus: Chapter 6: Trees : Tag: Data Structure, C++ Programing : Definition, concept, explanation with diagram - Binary Trees


Data Structures using C PlusPlus: Chapter 6: Trees



Under Subject


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Electron Devices

EC25C01 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Circuits and Network Analysis

EC25C02 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Engineering Drawing - Laboratory

ME25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus - Laboratory

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Devices and Circuits Laboratory

EC25C03 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation