## Sweta Kumari is teaching live on Unacademy Plus

WELCOME LEARNERS Unacademy, because learning is priceless INDIA'S LARGEST LEARNING PLATFORM unacademy

ABOUT ME top educator 2017 e My Name is SWETA KUMARI e Done B.TECH IN COMPUTER SCIENCE. Sweta Kumari Working as a Software Developer. : I have the desired capability and one B.TECH (CSE) From GGSIPU Software Engineer|Online Educator at Unacademy for Empowering Technical Programming in Students experience to how to deliver my knowledge in a unique way. FOLLOW M FOLLhttps://unacademy.com/user/hellosonuo1

Programming and Data Structures Height = Number of levels = 4 Height Max level number +1 TREES Root =4 Level 0 Level 1 Level 2 M) Level 3 A tree diagram

BINARY TREE

5 PROPERTIES OF TREE A HIERARCHICAL DATA STRUCTURE

PROPERTY The maximum number of nodes at level 1' of a binary tree is 21 Here level is number of nodes on path from root to the node (including root and node). Level of root is 1. This can be proved by induction. For root, l , number of nodes -21-1 Assume that maximum number of nodes on level I is 2-1 Since in Binary tree every node has at most 2 children, next level would have twice nodes, i.e. 2* 2-1

PROPERTY 2 Maximum number of nodes in a binary tree of height 'h' is 2h-1. Here height of a tree is maximum number of nodes on root to leaf path. : Height of a tree with single node is considered as 1. : This result can be derived from point 2 above. So maximum number of nodes in a binary tree of height h is 1+2+4+ This is a simple geometric series with h terms and sum of this series is 2h - In some books, height of a leaf is considered as 0. In this convention, the A tree has maximum nodes if all levels have maximum nodes. +2h-1. 1. above formula becomes 2h+1- 1

PROPERTY 3 In a Binary Tree with N nodes, minimum possible height or minimum number of levels is Log2(N+1) / : This can be directly derived from point 2 above. o If we consider the convention where height of a leaf node is considered as O, then above formula for minimum possible height becomes [Log2(N+1)1-1

PROPERTY A Binary Tree with L leaves has at least /Log2L /+1 levels. A Binary tree has maximum number of leaves (and minimum number of levels) when all levels are fully filled. Let all leaves be at level l, then below is true for number of leaves L. L 21-1 [From Point 1] 1= Log,L 1 + 1 where 1 is the minimum number of levels.

PROPERTY In Binary tree, number of leaf nodes is always one more than nodes with two children. Where LNumber of leaf nodes T = Number of internal nodes with two children