> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/algorithms-problem-solving-skills/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/algorithms-problem-solving-skills/graph-dfs-bfs/number-of-island-by-bfs.md).

# Number Of Island by BFS

BbQ (BFS = Queue)

앞의 "Number Of Island" 문제를 BFS 방법으로 풀어보겠다.

**알고리즘**

&#x20; **0. B**FS는 너비우선탐색이기 때문에 **Queue**를 이용한다! (**FIFO**)

1. DFS, BFS 모두 2차원 배열 형태의 인풋을 **좌표값**으로 형상화하여 푼다.

&#x20; 2\. 현재 좌표 위치(좌표값) 기준으로 상,하,좌,우 탐색한다! \
큐에 현재 좌표위치(좌표값) 넣고, 빼서 상/하/좌/우 위치값 더한다.- {{-1,0}, {1,0},{0,-1},{0,1}}

(DFS에서는 재귀 함수를 호출할 때 dfs(i-1,j) dfs(i+1,j) dfs(i,j-1) dfs(i,j+1) 이렇게 호출.)

알고리즘을 Java로

```
```

<br>
