Binary Tree REPORT
Binary Tree REPORT
FOR TOPIC
BINARY TREE
By:
Muhammad Mukarrum (02-134192-054)
Lavisha Chhatwani (02-134192-043)
Fatima Zafar (02-243212-010)
BSCS
Fall 2021
Submitted to:
Miss. Sameena Javaid
Table of Contents
Abstract 3
Introduction 4
Common terms 5
Types of trees 6
Applications of Binary Trees 8
2
Abstract
It is computationally efficient to perform operations on balanced binary trees. A balanced
binary tree must meet the following criteria: The absolute difference between the heights of
the left and right subtrees is smaller than one at each node. Each node's left subtree is
represented by a balanced binary tree. In the real world, dealing with random values is nearly
difficult, while dealing with non-random values (such as sequential) leads to skew trees, which
is the worst-case scenario. As a result, to establish height balance, rotations are required. We
will discuss binary tree in more detail.
3
Introduction
4
Common Terms
Root node: The topmost node in a tree
Parent node: Every node in a tree (excluding the root) is connected to exactly one other
node by a directed edge. This node is referred to as a parent.
Child node: When going away from the root, a child is a node that is directly related to
another node.
Leaf/external node: Node with no children
Internal node: Node having at least one child is referred to as an internal node.
Depth of a node: The number of edges from the root to the node is the depth of a node.
Height of a node: The number of edges from the node to the deepest leaf determines
the height of a node. The root's height is the tree's height.
The root node of the binary tree shown above is A. The tree comprises ten nodes, with
five internal (A,B,C,E,G) and five exterior (D,F,H,I,J) nodes. The tree stands at a height of
three meters. B is the father of D and E, while D and E are B's children.
Advantages of trees
Trees are so beneficial and widely used because they provide several significant benefits:
5
Insertion and searching are made easier with trees.
Trees are an extremely versatile type of data because they allow you to shift subtrees
around with little effort.
Types Of Trees
There are several types of trees, some of them are listed below:
1. Rooted binary tree: A rooted binary tree contains a root node and at most two children
for each node.
2. Full Binary Tree: Binary Tree in its Complete Form If every node has 0 or 2 offspring, it is
called a full binary tree. A whole binary tree is shown in the examples below. A full
binary tree is a binary tree in which all nodes have two offspring except the leaf nodes.
6
3. Perfect binary tree: A Perfect Binary Tree is one in which all internal nodes have two
offspring, and all leaf nodes are on the same level. Perfect Binary Trees are
demonstrated in the following cases:
The number of leaf nodes in a Perfect Binary Tree is equal to the number of internal
nodes plus one.
I + 1 = L Where L denotes the number of leaf nodes, and I denotes the number of
internal nodes.
There are 2h – 1 nodes in a Perfect Binary Tree of height h (where h is the longest
path from the root node to any leaf node in the tree, and the height of the root
node is 1).
4. Balanced binary tree: The height of a binary tree is balanced if it is O(Log n), where n is
the number of nodes. The AVL tree, for example, maintains O(Log n) height by ensuring
that the height difference between the left and right subtrees is no more than 1. Red-
Black trees keep their height constant by ensuring that the number of Black nodes on
each root-to-leaf path is the same and that no adjacent red nodes exist. Balanced Binary
Search trees provide good performance since they search, insert, and delete in O(log n)
time.
7
5. Degenerate tree: A tree with one child for each internal node. Such trees perform
similarly to linked lists in terms of performance.
In Microsoft Excel and spreadsheets, the binary tree is the default data structure.
The indexing of a Segmented Database is implemented using a Binary Tree.
In both hardware and software systems, the Splay Tree (Binary Tree version) is utilized
to construct efficient caches.
Back face culling, collision detection, Ray Tracing, and methods in rendering game
graphics all require Binary Space Partition Trees.
Compilers like as GCC, AOCL, and others use Syntax Trees (Binary Trees with nodes as
operations) to construct arithmetic expressions.
Priority Queue is implemented effectively using Binary Heap (Binary Tree form of Heap),
which is then used in the Heap Sort Algorithm.
In Hash Map implementations, the Binary Search Tree is utilized to effectively search
entries and as a collision handling mechanism.
To facilitate quick memory allocation, a Balanced Binary Search Tree is utilized to
represent memory.
The Huffman Tree (Binary Tree variation) is utilized internally in the Huffman Encoding
and Decoding Greedy Algorithm for Data Compression.
In Blockchain implementations and peer-to-peer (P2P) programmes that require
signatures, the Merkle Tree/ Hash Tree (Binary Tree version) is employed.
Binary Tries (Tries with two children) are used to represent routing data that vacillates in
terms of traversal efficiency.
Data is encoded using Morse code, which is represented using a Binary Tree.
Using an arbitrary pseudorandom generator, the Gold Reich, Goldwasser, and Micali
(GGM) Tree (Binary Tree variation) is used to construct pseudorandom functions.
The scapegoat tree (a self-balancing Binary Search Tree) is used to depict a defective
search process in Paul-Carole games.
treasury (randomized Binary Search Tree)
8
Operations of Binary Tree
There are three operations of binary tree, which are as under.
Insert: The very first insertion creates the tree. Afterwards, whenever an element is to
be inserted, first locate its proper location. Start searching from the root node, then if
the data is less than the key value, search for the empty location in the left subtree and
insert the data.
Search: Whenever an element is to be searched, start searching from the root node,
then if the data is less than the key value, search for the element in the left subtree.
Otherwise, search for the element in the right subtree.
Deletion: refers to the act of removal of a node from the binary tree , in deletion we
remove the element by replacing it with the rightmost element and delete the
rightmost leaf node when it is replaced.
Conclusion
One of the most often used trees in data structures is the binary tree. Each binary tree type has
its own set of characteristics. In applied computer science, these structures have certain
criteria. We hope you found this report on binary tree types, applications, and properties
useful.
10
REFERENCES
https://www.geeksforgeeks.org/binary-tree-set-1-introduction/
https://www.geeksforgeeks.org/binary-tree-set-2-properties/
https://www.geeksforgeeks.org/binary-tree-set-3-types-of-binary-tree/
https://www.studytonight.com/data-structures/introduction-to-binary-trees
https://owl.purdue.edu/owl/research_and_citation/ieee_style/ieee_general_format.html
http://www.differencebetween.net/technology/difference-between-binary-tree-and-binary-
search-tree/
https://iq.opengenus.org/applications-of-binary-tree/
11