Array Shift In Javascript Time Complexity Of Bfs In Graph