|
|
Apply the distancesFrom() method to the graph twice, once using vertex 4 as the source and another time using vertex 1 as the source.
Each time, show your work by filling in the missing details in the figures below. The first figure is to describe the sequence of operations that were performed upon the queue, in the manner illustrated both in lecture and on the web page pertaining to queues. The second one is for showing the final contents of the dist[] array.
It is recommended that you copy-and-paste the figures below into a text editor, fill in what's missing, and save the result in a file, which can then be submitted. The jGrasp editor should be suitable for this purpose.
+----+----+----+----+----+----+----+----+----+----+ | | | | | | | | | | | queue | | | | | | | | | | | | | | | | | | | | | | +----+----+----+----+----+----+----+----+----+----+ enq ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ deq ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ |
0 1 2 3 4 5 6 7 8 9 +----+----+----+----+----+----+----+----+----+----+ | | | | | | | | | | | dist | | | | | | | | | | | | | | | | | | | | | | +----+----+----+----+----+----+----+----+----+----+ |