adding the 3 pivots algorithm prototype