Finished BFS with fixed array initialization