제로베이스/알고리즘

Algorithms. DFS(Depth First Search) 알고리즘

진주네카라 2021. 11. 2. 01:49
728x90

깊이 우선 순회

  • DFS(Depth First Search) 
    • 스택(Stack)
      • 물건을 쌓아 올림
    • LIFO 구조
      • 나중에 들어온 것이 먼저 나간다.
      • last in, first out

 

DFS 기본

 

깊이 우선 순회(DFS)는 트리 아래로 내려 갈 수 있으면 항상 아래로 내려가고,

더 이상 아래로 내려갈 화살표가 없는 경우에만 옆에 있는 화살표로 넘어간다.

 

img. https://dev.to/danimal92/difference-between-depth-first-search-and-breadth-first-search-6om

 

 

+ 코드 구현

728x90

'제로베이스 > 알고리즘' 카테고리의 다른 글

Algorithms. 순위  (0) 2021.11.29
Algorithms. 이진 검색 예시  (0) 2021.11.12
Algorithms. 이진 검색  (0) 2021.11.10
Algorithms. 선형 검색 예시  (0) 2021.11.09
Algorithms. 선형 검색  (0) 2021.11.05