Print Path


Document last modified: 
Print-Path (G, s, v)
--  pre: BFS has been run on G with vertex s
-- post: the shortest path from s to v is printed if it exists
1 if v = s then
2    print s
3    else if v.p = NIL then
4       print "no path from " s " to " v " exists"
        else
5          Print-Path (G, s, v.p)
6          print v
 

Question 22.10.2 - Execute Print-Path( G, s, u ) for the following:

  r s t u v w x y
p s NIL w t r s w x
d 1 0 2 3 2 1 2 3