Variants of Binary Search
(Using recursive approach)
A thread 🧵
Binary search can be upgraded to the following five variants -
🔸Index of a particular key
🔸Index of the first occurrence of a key
🔸Index of the last occurrence of a key
🔸Index of least element greater than key
🔸Index of greatest element less than key
🔸A tree
The nodes that give birth to other nodes under them is called a "parent node" and its children are simply called "daughter node" or "children nodes". The main stem of the tree is called the "root node".
🔸Family
The family of Mr. Alpha can be represented as a tree where Mr. Alpha has two children - Mr. Charlie and Mr. Romeo and similarly they both have two children.