add circular queue and binary search