Added cartesian tree implementation.