 Hello everyone, my name is Nikhil Gajjam working as assistant professor in CSE department from Valchan Institute of Technology, Solapur. In today's session we will focus on binary tree terminologies. So this is a learning outcome at the end of this session, student will be able to acquaint with binary tree and binary search tree. Now this is a background before we start. Now there are two types of data structure. As we know data structure is nothing but organization of data so that we can insert and search or we can access the data easily. So there are majorly two types of data structure. First one is linear data structure and second one is non-linear data structure. In linear data structure, each element in the linear data structure have only one successor and only one predecessor. Examples of linear data structure are stack, queue and link list. Second type is non-linear data structure in which each element may have more than one successor or more than one predecessor. Major examples of non-linear data structure are tree and graph. In today's session we will focus on trees. So what is tree? Tree is non-linear data structure, it is a collection of nodes and edges. So general diagram of tree looks like this. So in this diagram, so circle indicating nodes and arrows indicating edges. Now we will see different definitions which are related to tree now. Definition one is node. So each element in the tree is called as node. So in diagram one, so m, b, r, e, etc., etc., are called as nodes. So it is represented by a circle. Next definition is edge. A line connecting to these nodes are called as edges, generally represented by arrows. Now next definition is child node. All immediate successor of a particular node is called as child nodes. In figure one, nodes q and v. So these are q and v, these are child nodes of node c and node d and t are child nodes of node e. So next definition is parent node. Immediate predecessor is a parent node of that node. Predecessor means a previous node. So node m is a parent node of node b, c, r and e. So next definition is root node. In tree, root node is a starting node. So node that do not have any parent is called as root node. In figure m is called as root node. Next definition is leaf node. Nodes that do not have any child nodes is called as leaf node. So in figure a, q, v, r, d, e, t are called as leaf nodes. So all leaf nodes do not have any child nodes. Next definition is level of the node and height of the tree. First we will consider a level of node. Level of node is a distance of a node from the root. So it is a distance from root to particular node. So level of root node is 0. So level of m is 0. Level of nodes b, c, r and e are at level 1 and nodes a, q, v, d, t are at level 2. So next definition is height of the tree. It is a total number of levels in a tree is called as height of the tree and it is generally one more than largest level of the tree. So height of the tree is generally considered for a complete tree not to a particular node. So height of this tree is 3. So maximum level is 2. So 2 plus 1 is nothing but height of that tree. Now we will see what is the definition of binary tree. In binary tree each node can have 0 or 1 or 2 children. So no node in the binary tree can have more than 2 children. In previous example that tree may have 4 children so that is not the binary tree. Now this is an example of binary tree. Every node can have maximum 2 children. Now tell me the answer what is the maximum number of nodes may be present in a tree with height 5. You can pause the video and you can answer. Answer of this question is 31. So maximum 31 nodes may be present in a tree with height 5. Now these are different properties of binary tree. Property 1 maximum number of nodes on any level i is 2 raised to i. So at level 0 number of nodes is 1 that is a root node. At level 1 number of nodes is 2. At level 2 number of nodes is 2 raised to 2 is 4 like this. So maximum number of nodes on any level i is 2 raised to i. Next one maximum number of nodes possible in a binary tree of height h is 2 raised to h minus 1. So in previous question I have asked the question maximum number of nodes in a binary tree with height 5 is 31. So 2 raised to 5 is 32 32 minus 1 is 31. Next property maximum number of nodes in a tree with height sorry minimum number of nodes in a tree with height h is h. So at every level only one node is there. So minimum numbers of height h is h. So next definition is strictly binary tree. In strictly binary tree each node can have either 0 or 2 children. In other words we can say no node have 1 children. So no node in strictly binary tree can have 1 children. So in tree this is an example of strictly binary tree. So each node can have maximum 2 children. So leaf node have no children. So this is example of strictly binary tree. Next definition is full binary tree. In full binary tree all levels have maximum number of nodes. So we have seen the property maximum number of nodes at any level is 2 raised to i. So in full binary tree all the levels are filled with maximum number of nodes. In full binary tree if height of binary tree is h then it will have 2 raised to h minus 1 nodes. So this is an example or diagram of full binary tree. Next definition is complete binary tree. In complete binary tree all the levels have maximum number of nodes except the last level. In full binary tree all the levels are filled with maximum number of nodes. It is similar to complete binary tree, but in complete binary tree except last level all the levels are filled with maximum number of nodes. So this is an example of complete binary tree. Next one important is binary search tree we call it as BST. In BST each node on left subtree is having value less than or equal to its parent and each node on the right subtree is having value greater than its parent. So this is a property of binary search tree. Example is this one. So 50 is the root node. So all the nodes present on left hand side of 50 are less than 50 and all the nodes present on right hand side of 50 are greater than 50. This property is applicable for all the nodes. So take an example of 25. So 10 is present on left hand side of 25. So 10 is less than 25, 40 is greater than 25, so 40 is present on the right hand side of 25. Similarly here 60 is less than 70, so 60 is present on the left hand side of 70. So this is a property of binary search tree. Now pause the video and answer this whether the given tree is binary tree or not. Answer is yes. There is a basic difference between binary tree and binary search tree. Binary search tree is a binary tree with having extra property as all the nodes present on the left hand side are less than its parent and all the nodes present on right hand side are greater than its parent. So this is a basic property of binary search tree. In question I have asked you whether this tree is binary tree or not. In binary tree each node can have maximum 2 children. So each node can have 0 or 1 or 2 children. So in this example each node have maximum 2 children. So this is an example of binary tree. This is not an example of binary search tree. These are the references I have used for creation of this video. Thank you.