From 9438727f61f0d91f0c3cbdeb29ce1b6592a8139d Mon Sep 17 00:00:00 2001 From: Tejas Amle Date: Tue, 22 Oct 2019 14:11:50 +0530 Subject: [PATCH] Added - What is BST --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index f2b5058..9ac5bcb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ # BinarySearchTree A binary search tree which includes insertion, deletion, inorder printing of the string. +##Added by Tejas Amle + +A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties − + +The left sub-tree of a node has a key less than or equal to its parent node's key. + +The right sub-tree of a node has a key greater than to its parent node's key. + +Thus, BST divides all its sub-trees into two segments; the left sub-tree and the right sub-tree and can be defined as − + +left_subtree (keys) ≤ node (key) ≤ right_subtree (keys) +Representation +BST is a collection of nodes arranged in a way where they maintain BST properties. Each node has a key and an associated value. While searching, the desired key is compared to the keys in BST and if found, the associated value is retrieved. + +Following is a pictorial representation of BST − + +Binary Search Tree +We observe that the root node key (27) has all less-valued keys on the left sub-tree and the higher valued keys on the right sub-tree. + +Basic Operations +Following are the basic operations of a tree − + +Search − Searches an element in a tree. + +Insert − Inserts an element in a tree. + +Pre-order Traversal − Traverses a tree in a pre-order manner. + +In-order Traversal − Traverses a tree in an in-order manner. + +Post-order Traversal − Traverses a tree in a post-order manner.