DFS
| time | O(n) |
|---|---|
| When Recursive | Set |
| Without Recursion | Stack needed |
BFS
Usually, non recursive.
| time | O(n) |
|---|---|
| Data Structure | Queue and Set |
Dijkstra’s Shortest Path
| time | O(ElogV) |
|---|---|
| Data Structure | Heap (priority queue) and Sets |
E:Edges, V:Vertices
| time | O(n) |
|---|---|
| When Recursive | Set |
| Without Recursion | Stack needed |
Usually, non recursive.
| time | O(n) |
|---|---|
| Data Structure | Queue and Set |
| time | O(ElogV) |
|---|---|
| Data Structure | Heap (priority queue) and Sets |
E:Edges, V:Vertices