Quiz question 02
a.) Common: They both use an adjacency list as input. Both of them can be used to calculate distances and classify edges.
Differences: BFS doesn't restart the search when it reaches a target node or when a tree is finished like DFS does. BFS visits all nodes reachable from a given node, so not necessarily the entire tree will be visited.
b.) Common: they both use an adjancency list and starting + ending times of node's visits as input.
Differences: BFS can be used to calculate distances and finding connected components. While DFS can be used to detect cycles and classify edges.
c.) Common: they both use an adjancency list as input.
Differences: BFS doesn't restart the search when it reaches a target node or when a tree is finished like DFS does. BFS visits all nodes reachable from a giving node, so not necessarily the entire tree will be visited.
d.) Common: they both need an adjancency list and starting times of node's visits as input.
Differences: DFS needs starting and ending times of node's visits to classify edges, while BFS just needs the starting time.
e) None of the above
Original idea by: Julia de Pietro Bigi
Comentários
Postar um comentário