50 likes | 57 Views
Binary search tree is a class of Binary trees in which all nodes are arranged in a specific order. A binary search tree is also called an ordered binary tree. <br><br>
E N D
What is a binary search tree in Data structure? Binary search tree is a class of Binary trees in which all nodes are arranged in a specific order. A binary search tree is also called an ordered binary tree. Features of Binary search tree: In a binary search tree, each node in the left subtree has a value less than or equal to the value of the root. In the same way, each node on the right subtree has a value greater than or equal to the value of the root.
This rule is repeated to all the right and left subtrees until it ends. What are the advantages of using a binary search tree in Data Structure? A binary search tree makes the search easy and efficient as at every step we get a hint if the desired value is located at the right subtree or left subtree. A binary search tree is much more efficient than an array or linked lists, as in the process of searching; at every step half subtree is removed. In a binary search tree, it takes o(log2n) time to complete the search. The worst-case time to make a search is 0(n). Where n is the number of elements. The insertion and deletion operation also becomes easy with a Binary search tree as compared to a linked list and array. Attributes of binary search tree: Binary search trees are made up of nodes and have the following attributes: Each node of a binary search tree is represented in a parent-child relationship. Each parent node has a minimum of zero and a maximum of two subnodes on the right and left sides. Each subtree also has sub-branches on their left and right sides. Each node of a binary search tree is linked with key-value pairs. The values of nodes on the left subtree are smaller than the value of the parent node. The values of nodes on the right subtree are greater than the value of the parent node Types of Binary Trees: There are four types of binary trees, which are: 1.Complete Binary tree 2.Full Binary Tree 3.Skewed Binary Tree 4.Extended Binary Tree
1.Complete binary tree: In a complete binary tree all the levels of the trees are filled. All internal nodes have two children in a complete binary tree. All the leaf nodes of a complete binary tree are at the same level. At level 2 there must be 4 nodes and level 3 has 8 nodes. 2.Full Binary Tree: In a full Binary tree, each node has two or zero sub-nodes. A full binary tree is also called a Strictly Binary tree.
3.Skewed Binary Tree : In a Skewed binary tree, most of the nodes have either left sub nodes or right subnodes. Left Skewed tree- In a left Skewed tree, all the nodes have left subnodes without having right subnodes. Right Skewed tree - In a right Skewed tree, all the nodes have right subnodes only without having left subnodes. 4.Extended Binary tree: In an extended binary tree, every empty subtree is replaced with special nodes. Each special node is called an external node and the nodes from the original tree are called an internal node. Each internal node has two children and the external node is a leaf in an extended binary tree. To know more about the binary search in data structure and types of binary search tree, do visit our website help me study bro.
A-109, 3rd floor, kaushambi, Pin code – 201010 +91-98737 95550 https://www.helpmestudybro.com/