Introduction to Algorithms — Red-Black Tree

1. Properties of red-black trees A red-black tree is a binary search tree with one extra bit of storage per node: its color, which can either RED or BLACK. By constraining the node colors on any simple path from the root to a leaf, red-black trees ensure that no such path is more than twice … Continue reading Introduction to Algorithms — Red-Black Tree

Introduction-to-algorithms — dynamic programmimng

Dynamic programming typically applies to optimization problems in which we make a set of choices in order to arrive at an optimal solution. As we make each choice, subproblems of the same form often arise. Dynamic programming is effective when a given subproblem may arise form more than one partial set of choices. The key … Continue reading Introduction-to-algorithms — dynamic programmimng

334. Increasing Triplet Subsequence

Difficulty: Medium Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Return true if there exists i, j, k such that 1arr[i] < arr[j] < arr[k] given 10 ≤ i < j < k ≤ n-1 else return false. Your algorithm should … Continue reading 334. Increasing Triplet Subsequence