[Bona1122] 25.02.20 #49
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[그래프]
문제를 풀면서 나온 개념인 DFS/BFS, 다익스트라 알고리즘에 대해 배운 내용을 정리했습니다.
DFS/BFS
DFS,BFS는 그래프에서 모든 노드를 탐색하는 기본적인 방법이다.
DFS와 BFS 비교
DFS
BFS
BFS는 그래프의 모든 간선 비용이 동일하면, 최단거리/최소횟수 탐색에 쓰이기도한다.
시작노드를 큐에 삽입하고 방문처리
큐에서 노드를 꺼내고, 인접한 방문하지 않은 노드를 큐에 삽입/방문처리 - 계속 반복
다익스트라 알고리즘
다익스트라 알고리즘은 최단 경로 알고리즘과 그리디 알고리즘의 일종으로,
한 노드에서 다른 모든 노드로 가는 최단 경로를 계산할 때 사용한다. (모든 지점에서 다른 모든 지점까지의 최단 경로는 플로이드 워셜 알고리즘 이용)
+) 음의 간선이 포함되지 않은 경우만 사용 가능하며, 음의 간선이 포함된 경우는 벨만포드 알고리즘을 활용할 수 있다.
+) 매 상황, 방문하지않은 노드 중, 가장 비용이 적은 노드 선택해서 반복하기에 그리디 알고리즘이다.
+) 다익스트라는 중복간선이 있어도 동작하는 알고리즘이다.
+)우선순위 큐: 우선순위가 높은 데이터부터 삭제
다익스트라 수행 시, 테이블에 한 노드의 각 노드까지의 최단거리정보가 저장된다. (최단거리가 아닌, 경로를 구하려면 부모 배열을 이용한 역추적이나, 역방향 그래프를 이용한 BFS 역추적 구현이 추가적으로 필요)📌 푼 문제
📝 간단한 풀이 과정
게임 맵 최단거리
타겟 넘버
전력망을 둘로 나누기
배달
미로 탈출