Category: Binary Search Tree
Designing a Binary Search Tree Validation class
Many times we need to validate a Binary Search tree i.e. verifying its properties, Left subtree of each node contains the nodes with value less than the node’s value. Right subtree of each node contains the nodes with value greater than the node’s value. Moreover, left and right subtree of each node must be a …
Converting a Binary Search Tree to a Sorted Doubly Linked List
Change the left and right pointers of each node in Binary search Tree to make it a sorted doubly linked list. Method: Just do the Post order traversal and while visiting the node, Advertisements    Point the left link of visiting node to right most node in left tree.    Point the right link of …
Converting a Binary Search Tree to a Sorted Doubly Linked ListRead More
Finding nth Largest and Smallest Node in Binary Seach Tree
Binary Search Tree Concept: In Binary Search Tree, Advertisements When we do the In-Order traversal, nodes will be visited in ascending order.In-Order Traversal For each Node, Traverse the left subtree Visit the node Traverse the right subtree i.e. for above BST, nodes will be visited in following order, 1 , 3 , 4 , 5 …
Finding nth Largest and Smallest Node in Binary Seach TreeRead More
Create a Binary Search Tree from an array
Lets discuss how to create a BST From an array. Advertisements Tree’s node structure is as follows, typedef struct node { int value; node * pLeft; node * pRight; node(int val = 0) { value = val; pRight = NULL; pLeft = NULL; } }node; Now create a getBST function that accepts an integer pointer …