Posts

Showing posts from April, 2022
Image
  Binary Search Tree  The following is the definition of Binary Search Tree (BST) according to  Wikipedia Binary Search Tree is a node-based binary tree data structure which has the following properties:   The left subtree of a node contains only nodes with keys lesser than the node’s key. The right subtree of a node contains only nodes with keys greater than the node’s key. The left and right subtree each must also be a binary search tree.  There must be no duplicate The above properties of Binary Search Tree provides an ordering among keys so that the operations like search, minimum and maximum can be done fast. If there is no ordering, then we may have to compare every key to search for a given key. Searching a key   For searching a value, if we had a sorted array we could have performed a binary search. Let’s say we want to search a number in the array, in binary search, we first define the complete list as our search space, the number can exist on...