0% found this document useful (0 votes)
301 views12 pages

Binary Tree

This document provides information about binary trees, including: - Binary trees have nodes with two pointers - left and right child of the parent node. - There are different types of binary trees classified by their structure, including full, complete, perfect, balanced, degenerate, and skewed binary trees. - Operations on binary trees include insertion, deletion, traversal, and searching. - Binary trees have applications in storing hierarchical data, databases, computer networks, and digital image compositing.

Uploaded by

Debasis Garai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
301 views12 pages

Binary Tree

This document provides information about binary trees, including: - Binary trees have nodes with two pointers - left and right child of the parent node. - There are different types of binary trees classified by their structure, including full, complete, perfect, balanced, degenerate, and skewed binary trees. - Operations on binary trees include insertion, deletion, traversal, and searching. - Binary trees have applications in storing hierarchical data, databases, computer networks, and digital image compositing.

Uploaded by

Debasis Garai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

WELCOME

NSHM KNOWLEDGE CAMPUS, DURGAPUR-


GOI (College Code: 273)
CA1 Assessment

BINARY TREE

Presented By
Student Name: DEBASIS GARAI
University Roll No.: 27300121013
University Registration No.: 212730100110040(2021-22)

Branch: Computer ScienceEngineering


Year: 2nd
Semester: 3rd
Paper Name: DATA STRUCTURE AND ALGORITHMS
Paper Code: PCC-CS-301
TABLE OF CONTENTS

 WHAT IS A BIMARY TREE?


 PROPERTIES OF A BINARY TREE
 CLASSIFICATION OF BINARY
TREES
:
 Full binary tree
 Complete binary tree
 Perfect binary tree
 Balanced binary tree
 Degenerate binary tree
 Skewed binary tree
 Operations on a binary tree
 Applications of binary tree
WHAT IS A BINARY TREE ?

A tree is a popular data structure that is non-linear in nature. Unlike other data
structures like array, stack, queue, and linked list which are linear in nature, a
tree represents a hierarchical structure. A tree contains nodes and 2 pointers.
These two pointers are the left child and the right child of the parent node. The
terms of tree in detail:
•Root: The root of a tree is the topmost node of the tree that has no parent
node. There is only one root node in every tree.
•Edge: Edge acts as a link between the parent node and the child node.
•Leaf: A node that has no child is known as the leaf node. It is the last node of
the tree. There can be multiple leaf nodes in a tree.
•Depth: The depth of the node is the distance from the root node to that
particular node.
•Height: The height of the node is the distance from that node to the deepest
node of the tree.
•Height of tree: The Height of the tree is the maximum height of any node.
PROPERTIES OF A BINARY
TREE

 1) The maximum number of nodes at level ‘l’ of a binary tree is 2 l.


 2) The Maximum number of nodes in a binary tree of height ‘h’ is
2h – 1.
 3) In a Binary Tree with N nodes, minimum possible height
or the minimum number of levels is Log2(N+1).
 4) A Binary Tree with L leaves has at least | Log2L |+ 1 levels.
 5) In Binary tree where every node has 0 or 2 children, the number
of leaf nodes is always one more than nodes with two children.
 6) In a non empty binary tree, if n is the total number of nodes and
e is the total number of edges, then e = n-1
CLASSIFICARION OF
BINARY TREES

There are various types of binary


trees, and each of these binary tree
types has unique characteristics. Here
are each of the binary tree types :
 1. Full Binary Tree
 2. Complete Binary Tree
 3. Perfect Binary Tree
 4. Balanced Binary Tree
 5. Degenerate Binary Tree
 6.Skewed Binary Tree
FULL BINARY
TREE : COMPLETE BINARY TREE:

 A Binary Tree is a full binary tree if


every node has 0 or 2 children.  A Binary Tree is a Complete Binary Tree if all
 It can be also said that a full binary the levels are completely filled except possibly
tree is a binary tree in which all the last level and the last level has all keys as
nodes except leaf nodes have two left as possible.
children. A complete binary tree is just like a full binary
 It is also known as a proper binary tree, but with two major differences:
tree. •Every level must be completely filled
•All the leaf elements must lean towards the left.
•The last leaf element might not have a right
sibling i.e. a complete binary tree doesn’t have to
be a full binary tree.
PERFECT BINARY BALANCED BINARY
TREE : TREE :

 A Binary tree is a Perfect Binary


Tree in which all the internal  A binary tree is balanced if the height of the tree is O(Log
nodes have two children and all n) where n is the number of nodes.
leaf nodes are at the same level.  For Example, the AVL tree maintains O(Log n) height by
The following are the examples making sure that the difference between the heights of the
of Perfect Binary Trees. left and right subtrees is at most 1.
A Perfect Binary Tree of height h  Red-Black trees maintain O(Log n) height by making sure
(where the height of the binary tree that the number of Black nodes on every root to leaf paths
is the number of edges in the is the same and there are no adjacent red nodes.
longest path from the root node to  Balanced Binary Search trees are performance-wise good
any leaf node in the tree, height of as they provide O(log n) time for search, insert and delete.
root node is 0) has 2h+1 – 1 node.  It is a type of binary tree in which the difference between
the height of the left and the right subtree for each node is
either 0 or 1. In the figure above, the root node having a
value 0 is unbalanced with a depth of 2 units.
DEGENERATE BINARY
TREE :
SKEWED BINARY
TREE :

 A Tree where every


internal node has one
child.
 Such trees are  A skewed binary tree is a
performance-wise same pathological/degenerate tree in which the
as linked list. tree is either dominated by the left nodes or
 A degenerate or the right nodes.
pathological tree is the  Thus, there are two types of skewed binary
tree having a single child tree: left-skewed binary tree and right-
either left or right. skewed binary tree.
Operations on a binary
tree :

 Insertion : Nodes can be inserted into


binary trees in between two other nodes or
added after a leaf node. In binary trees, a
node that is inserted is specified as to
which child it is.
 Deletion : It is a process where a node is
removed from the tree. Only certain nodes
can be deleted unambiguously
 Traversal :Pre-order, in-order, and post-
order traversal visit each node in a tree by
recursively visiting each node in the left
and right subtrees of the root.
 Searching : searches for an element in the
tree.
Applications of binary
tree :

 We can insert/delete keys in moderate time (quicker than Arrays and slower than
Unordered Linked Lists). Self-balancing search trees like AVL and Red-Black trees
guarantee an upper bound of O(Logn) for insertion/deletion.
 Like Linked Lists and unlike Arrays, Pointer implementation of trees don’t have an
upper limit on number of nodes as nodes are linked using pointers.
 Store hierarchical data, like folder structure, organization structure, XML/HTML
data.
 B-Tree and B+ Tree are used to implement indexing in databases.
 Spanning Trees and shortest path trees are used in routers and bridges respectively
in computer networks.
 As a workflow for compositing digital images for visual effects.
TH
AN
K
YO
U

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy