A tree in which all the nodes follow some of the properties which are listed below, is a Binary Search Tree (BST).
All the sub-trees are divided into two segments – left sub-tree and right sub-tree in BST. The segments are defined by the code -
The collection of nodes which are arranged in a manner in which BST properties are maintained is known as BST. Each node possess a key and a value associated to it. The desired key is compared to the Keys available in the BST for searching and if found, the value associated is retrieved.
The pictorial representation of BST is -
It is observed 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.
What are the basic operations supported by Data Structure BST?
The basic operations supported by a BST are -
A node with some data is defined, references to its left and right child nodes.
An element is searched from the root node. If the data is less than key value, the element is searched in the left subtree. If not, the element is searched in the right subtree. Same algorithm is followed for each node.
An element is inserted by locating the proper location. First search the root node, then if the data is less than the key value, search for the empty location in the left subtree and insert the data. Otherwise, search for the empty location in the right subtree and insert the data.
Data Structure & Algorithms Related Interview Questions
|RDBMS Interview Questions||DBMS Interview Questions|
|Adv Java Interview Questions||Core Java Interview Questions|
|C Interview Questions||Database Administration Interview Questions|
|CSS Advanced Interview Questions||Maven Interview Questions|
|Computer architecture Interview Questions||Object Oriented Analysis and Design Interview Questions|
|Standard Template Library (STL) Interview Questions||Xml Publisher Interview Questions|
Data Structure & Algorithms Tutorial
Data Structure & Algorithms
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.