add second algorithm that uses partition