Tag

Algorithm

Browsing

Red Black tree is self-balanced binary search tree with color information. The Red-Black tree nodes can be either red or black. The color ensures tree balance. The root node and all leaves node set with black color. When inserting new item in the red-black tree, the tree balanced based on these properties. The search operation similar to the binary search tree.

A binary search tree is a binary tree (contains only two nodes). The left subtree node data value is less than or equal to parent node data value and right subtree node data value is greater than or equal to parent node data value.

Binary search is a method to find the particular item in the sorted array. In each step, the algorithm divides the array equally and match the middle item. If the key match, return the index. If the key is less than the middle element, search left subarray. Else search right subarray.