Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE) PDF Download

The following are common types of Binary Trees:

  1. Full Binary Tree: A Binary Tree is a full binary tree if every node has 0 or 2 children. The following are the examples of a full binary tree. We can also say a full binary tree is a binary tree in which all nodes except leaf nodes have two children.
    Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE)
  2. Complete Binary Tree: A Binary Tree is a Complete Binary Tree if all the levels are completely filled except possibly the last level and the last level has all keys as left as possible
    The following are examples of Complete Binary Trees:
    Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE)
  3. Perfect Binary Tree A Binary tree is a Perfect Binary Tree in which all the internal nodes have two children and all leaf nodes are at the same level.
    The following are the examples of Perfect Binary Trees:
    Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE)In a Perfect Binary Tree, the number of leaf nodes is the number of internal nodes plus 1
    L = I + 1 Where L = Number of leaf nodes, I = Number of internal nodes.
    A Perfect Binary Tree of height h (where the height of the binary tree is the longest path from the root node to any leaf node in the tree, height of root node is 1) has 2h – 1 node.
    An example of a Perfect binary tree is ancestors in the family. Keep a person at root, parents as children, parents of parents as their children.
  4. Balanced Binary Tree: A binary tree is balanced if the height of the tree is O(Log n) where n is the number of nodes. For Example, the AVL tree maintains O(Log n) height by making sure that the difference between the heights of the left and right subtrees is at most 1. Red-Black trees maintain O(Log n) height by making sure that the number of Black nodes on every root to leaf paths is the same and there are no adjacent red nodes. Balanced Binary Search trees are performance-wise good as they provide O(log n) time for search, insert and delete.
  5. A degenerate (or pathological) tree: A Tree where every internal node has one child. Such trees are performance-wise same as linked list.
    Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE)
The document Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Programming and Data Structures.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
119 docs|30 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Types of Binary Trees - Programming and Data Structures - Computer Science Engineering (CSE)

1. What is a binary tree?
A binary tree is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child. The binary tree follows a specific order, such as the binary search tree, where the left child is always less than the parent node, and the right child is always greater.
2. What are the different types of binary trees?
There are several types of binary trees, including: - Full binary tree: A binary tree in which all nodes have either 0 or 2 children. - Complete binary tree: A binary tree in which all levels, except possibly the last one, are completely filled, and all nodes are as left as possible. - Perfect binary tree: A binary tree in which all internal nodes have exactly two children, and all leaves are at the same level. - Balanced binary tree: A binary tree in which the left and right subtrees of every node differ in height by at most 1.
3. What is the height of a binary tree?
The height of a binary tree is the length of the longest path from the root to a leaf node. It represents the number of edges on the longest downward path from the root to a leaf.
4. How can we represent a binary tree in memory?
A binary tree can be represented in memory using various data structures. The most common representation is through linked nodes, where each node contains a value and pointers to its left and right children. Another representation is through an array, where the elements are stored in a specific order to maintain the binary tree structure.
5. What is the time complexity of searching a node in a binary tree?
The time complexity of searching a node in a binary tree depends on the type of binary tree and its structure. In a balanced binary tree, such as an AVL tree or a red-black tree, the time complexity for searching is O(log n), where n is the number of nodes in the tree. However, in an unbalanced binary tree, the time complexity can be as bad as O(n), where n is the number of nodes in the tree.
119 docs|30 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Semester Notes

,

Extra Questions

,

video lectures

,

ppt

,

Free

,

Objective type Questions

,

shortcuts and tricks

,

Sample Paper

,

Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE)

,

mock tests for examination

,

Important questions

,

past year papers

,

Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE)

,

Summary

,

Previous Year Questions with Solutions

,

Types of Binary Trees | Programming and Data Structures - Computer Science Engineering (CSE)

,

Viva Questions

,

practice quizzes

,

pdf

,

study material

,

Exam

,

MCQs

;