Question: Part B: Path to goal Write new functions dis_path and bfs_path that take the same arguments as dis_traversal and bfs_traversal but that, instead of returning



Part B: Path to goal Write new functions dis_path and bfs_path that take the same arguments as dis_traversal and bfs_traversal but that, instead of returning the entire traversal, they only return the path from the start vertex to the goal vertex that has been reached. For example: >>> print_grid_traversal(g, 10, dfs_traversal(g, 0, {9, 39})) 000---001---002 - * * * * * *- -* * * ***---***-- --**# -003---025---026---027---029- -033- -035 * * * 022---018---004---016---017 028 030 034 036 023 019 005---006---008---015 031---032 037---038 024 020---021 007 009---010---011---012---013---014 >>> print_grid_traversal(g, 10, dfs_path(g, 0, {9, 39})) 000---001---002 --* ** * **---* ** * * *- -***- -** * -003--- -005-- -006---007- -008---009 -* * * 010 -* ** - -* *x---*xx 011---012 * * *- -* * * --*** Can you find inputs (by varying the input graph, the starting vertex and/ or the goal vertices) such that the bfs path is shorter than the dis path (although the corresponding dis traversal is shorter than the bfs traversal)? Discuss your findings in a short text in the doc string at the end of your module file. Include visualisations of your discovered example inputs by copying the corresponding output of the print_grid_traversal function.\fg = graphs. ex_tree print_grid_traversal (g, 10, dis_traversal (g, 0, {12))) 000---001---002 *4 4---14 4 > > > print_grid traversal (g, 10, dis_traversal (g, 0, {9, 40, 49))) 000---001---002 *: 4:4---14*--- 003---***---104--- * *4---14*--- 004---1**---14 005---006---008---**4 007 009---010---011---012---013---014
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
