2020/10/31 1

Graph | DFS(๊นŠ์ด ์šฐ์„  ํƒ์ƒ‰), BFS(๋„ˆ๋น„ ์šฐ์„  ํƒ์ƒ‰)

ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ด๋ฒˆ ์ฃผ๋Š” ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ๋Œ€ํ‘œ์ ์ธ ๋‘ ๊ฐ€์ง€ DFS์™€ BFS์— ๊ณต๋ถ€ํ•  ์˜ˆ์ •์ด๋‹ค. ๋จผ์ € ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ํŠธ๋ฆฌ ๊ตฌ์กฐ๋กœ ๋งŒ๋“ค์–ด์ง„ ๊ทธ๋ž˜ํ”„์˜ ๋…ธ๋“œ ๊ทธ๋ฆฌ๊ณ  ๋…ธ๋“œ์™€ ๋…ธ๋“œ ์‚ฌ์ด์— ์—ฐ๊ฒฐ๋œ ๊ฐ„์„ ์˜ ์ƒํƒœ๋ฅผ ํŒŒ์•…ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค. ๋จผ์ €, ๊ทธ๋ž˜ํ”„๋ฅผ ๋ฐ์ดํ„ฐ๋กœ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋จผ์ € ํ…Œ์ด๋ธ”์— ๋Œ€ํ•œ ์ดํ•ด๊ฐ€ ์žˆ์–ด์•ผ ํ•˜๋ฉฐ, ์ด๋Š” ์ธ์ ‘ ํ–‰๋ ฌ ๋˜๋Š” ์ธ์ ‘ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ด์šฉํ•ด์„œ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค. Graph [์ž๋ฃŒ๊ตฌ์กฐ] ๊ทธ๋ž˜ํ”„(Graph)๋ž€ - Heee's Development Blog Step by step goes a long way. gmlwjd9405.github.io ์ธ์ ‘ ํ–‰๋ ฌ ์ธ์ ‘ ํ–‰๋ ฌ์ด๋ž€ ๊ทธ๋ž˜ํ”„์˜ ์—ฐ๊ฒฐ ๊ด€๊ณ„๋ฅผ 2์ฐจ์› ๋ฐฐ์—ด๋กœ ํ‘œํ˜„ํ•˜๋Š” ๋ฐฉ์‹์„ ๋งํ•œ๋‹ค. ์ฆ‰, ๋…ธ๋“œ์˜ ๊ฐœ์ˆ˜๋Š” ์ด๋ฏธ ์ •ํ•ด์ ธ ์žˆ์œผ๋‹ˆ ๊ฐ ๋…ธ๋“œ(x์ถ• index ๋ฒˆํ˜ธ)์™€..

Algorithm 2020.10.31