Queue insertion using binary search