알고리즘 인터뷰 준비용

BFS vs DFS
Advantages of BFS:
1. Solution will definitely found out by BFS If there are some solution.
2. BFS will never get trapped in blind alley , means unwanted nodes.
3. If there are more than one solution then it will find solution with minimal steps.
Disadvantages Of BFS :
1. Memory Constraints As it stores all the nodes of present level to go for next level.
2. If solution is far away then it consumes time.

Advantages Of DFS :
1. Memory requirement is Linear WRT Nodes.
2. Less time and space complexity rather than BFS.
3. Solution can be found out by without much more search.
Disadvantage of DFS :
1. Not Guaranteed that it will give you solution.
2. Cut-off depth is smaller so time complexity is more.
3. Determination of depth until the search has proceeds.

Use Examples:
BFS: Finding shortest path
DFS: topological sort (listing vertices following the direction of edges)
(https://jason9319.tistory.com/93)


Dijkstra:
Using Array: https://www.crocus.co.kr/533
Using Priority Queue: https://hsp1116.tistory.com/42

댓글

이 블로그의 인기 게시물

[Django REST Framework] create() vs perform_create()

[웹 보안] CORS란?

3. GRAPHQL FRAGMENTS