BFS & update binary search