21 September, 2018
A binary search tree is a binary tree that may be empty A no-empty binary search tree in data structures satisfy the following properties :
Searching BST :
10<20. right 30>20, left 25>20, left insert 20 on left Example : instruct a binary search tree with the following elements. 12,5,18,2,9,15,19,13,17 And traverse the binary search tree in zn order, preorder, post order Preorder : 12 529 1815131719 In order: 259 12 1315171819 Post order:295 131715191812
For element removal we consider the three possibilities for the node P that contains the element to be removed.
Case 1: First cape is handled by discarding the root, The root is set to null. Case 2: Next consider the case when the element to be removed is in ia node P that has only one non empty sub tree. IF P has no parent (i.e it is root), The root of its single sub tree becomes the new search tree root. IF p has a parent pp, then we change the pointer from PP so that it points to p’s only child. ex : Delete 5 Case 3: Finally, to remove an element in a node that has two no empty sub trees, we replace this element with either the largest element in its left sub tree or the smallest element in its right sub tree. Following this replacement, the replacing element is removed from its original node Ex : Deleting 50
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .