An efficient solution based on hash map is discussed. We need to check the Horizontal Distances from root for all nodes and two nodes have the same
binary tree
Sorted order printing of a given array that represents a BST – Binary Search Tree – Given an array that stores a complete Binary Search Tree,
An efficient solution based on hash map is discussed. We need to check the Horizontal Distances from root for all nodes and two nodes have the same.
C Program Lowest Common Ancestor in a Binary Search Tree – Data Structure – write a c program to find the Lowest Common Ancestor (LCA).
python Programming Inorder predecessor and successor for a given key in BST – I recently encountered with a question in an interview at e-commerce company.
Python Program – Find the node with minimum value in a Binary Search Tree – Just traverse the node from root to left recursively until left is NULL.
Binary Insertion Sort – Searching and Sorting – We can use binary search to reduce the number of comparisons in normal insertion sort. Binary Insertion Sort find use binary search to find the proper location to insert the selected item at each iteration.
A Problem in Many Binary Search Implementations – Searching and Sorting – The above looks fine except one subtle thing, the expression “m = (l+r)/2”. It fails for large values of l and r. Specifically, it fails if the sum of low and high is greater than the maximum positive int value (231– 1).
ShellSort – Searching and Sorting – ShellSort is mainly a variation of Insertion Sort. In insertion sort, we move elements only one position ahead. When an element has to be moved far ahead, many movements are involved.
Bucket Sort – Searching and sorting – A simple way is to apply a comparison based sorting algorithm. The lower bound for Comparison based sorting algorithm (Merge Sort, Heap Sort, Quick-Sort .. etc) is Ω(n Log n), i.e., they cannot do better than nLogn.