0% found this document useful (0 votes)
57 views18 pages

BCA 3.3 Non Linear Data Structure Using C++

This document discusses binary trees and their representation using C++. It covers array and linked list representations of binary trees, types of binary trees such as full, complete, perfect, balanced, and degenerate binary trees. It also includes learning objectives about understanding binary tree representation and types, session outcomes of being able to understand this, and sample multiple choice questions to assess learning.

Uploaded by

UMESH SIRMV
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)
57 views18 pages

BCA 3.3 Non Linear Data Structure Using C++

This document discusses binary trees and their representation using C++. It covers array and linked list representations of binary trees, types of binary trees such as full, complete, perfect, balanced, and degenerate binary trees. It also includes learning objectives about understanding binary tree representation and types, session outcomes of being able to understand this, and sample multiple choice questions to assess learning.

Uploaded by

UMESH SIRMV
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/ 18

BCA 3.

3 Non Linear Data structure using C++

Program BCA
Subject Non Linear Data structure using C++
Semester III
University Kuvempu university
Session 38
BCA 3.3 Non Linear Data structure using C++

Unit 04
Title Trees and Sorting

Sub – title binary tree representation, types of binary


tree - linked representation
Recap of previous class

Understanding the Tree terminologies, Binary tree


Learning objectives

To understand the binary tree representation, types of


binary tree - linked representation

 
Session Outcomes

The Student will be able to understand binary tree


representation, types of binary tree - linked
representation
Binary Tree Representation

A binary tree data structure is represented using two


methods. Those methods are as follows
 1. Array Representation
2. Linked List Representation
Consider the following binary tree...
1. Array Representation of Binary Tree

– In array representation of a binary tree, we use one-


dimensional array (1-D Array) to represent a binary tree.
– Consider the above example of a binary tree and it is
represented as follows...

– To represent a binary tree of depth 'n' using array


representation, we need one dimensional array with a
maximum size of 2n + 1.
2. Linked List Representation of Binary Tree

• We use a double linked list to represent a binary tree. In


a double linked list, every node consists of three fields.
First field for storing left child address, second for storing
actual data and third for storing right child address. In
this linked list representation, a node has the following
structure...
• The above example of the binary tree represented using
Linked list representation is shown as follows...
Types Of Binary Tree

• Full Binary Tree


– Full Binary Tree is a Binary Tree in which every node has 0 or 2 children.
• Complete Binary Tree
– Complete Binary Tree has all levels completely filled with nodes except the
last level and in the last level, all the nodes are as left side as possible.
• Perfect Binary Tree
– Perfect Binary Tree is a Binary Tree in which all internal nodes have 2 children
and all the leaf nodes are at the same depth or same level.
• Balance Binary tree
– Balanced Binary Tree is a Binary tree in which height of the left and the right
subtrees of every node may differ by at most 1
• Degenerate Binary Tree
– Degenerate Binary Tree is a Binary Tree where every parent node has only
one child node.
MCQs
1. What is a complete binary tree?
a) Each node has exactly zero or two children
b) A binary tree, which is completely filled, with the
possible exception of the bottom level, which is filled
from right to left
c) A binary tree, which is completely filled, with the
possible exception of the bottom level, which is filled
from left to right
d) A tree In which all nodes have degree 2
Answer c
2What is a full binary tree?
a) Each node has exactly zero or two children
b) Each node has exactly two children
c) All the leaves are at the same level
d) Each node has exactly one or two children
ANS:a)
 What is a complete binary tree?
a) Each node has exactly zero or two children
b) A binary tree, which is completely filled, with the
possible exception of the bottom level, which is filled
from right to left
c) A binary tree, which is completely filled, with the
possible exception of the bottom level, which is filled
from left to right
d) A tree In which all nodes have degree 2
Ans: c)
4.  What is the average case time complexity for
finding the height of the binary tree?
a) h = O(loglogn)
b) h = O(nlogn)
c) h = O(n)
d) h = O(log n)
Ans d)
5. Which of the following is not an advantage of
trees?
a) Hierarchical structure
b) Faster search
c) Router algorithms
d) Undo/Redo operations in a notepad
Ans: d
Session Summary

 The Student can be able to understand tree


representation, types of binary tree - linked
representation
Reference

Author: E Balaguruswamy
Title of the book: Object Oriented Programming with C++  

You might also like