74Chap. 11 Graphs2345611013126 223516123815 15411105311.16The problem is that each entry of the array is set independently, forcing pro-cessing of the adjacency list repeatedly from the beginning. This illustratesthe dangers involved in thoughtlessly using an ineffcient access member to adata structure implementation. A better solution is to process the actual edgeswithin the graph. In other words, for each vertex, visit its adjacency list. Setthe shortest-paths array by setting the values associated with that edge. If thearray is initialized with values of∞, then any vertices not connected by anedge will retain that value.11.17Clearly the algorithm requires at leastΩ(n2)time since this much informa-tion must be produced in the end. A stronger lower bound is diffcult toobtain, and certainly beyond the ability of students at this level. The primarygoal of this exercise is for the students to demonstrate understanding of theconcept of a lower bound on a problem, in a context where they will not beable to make the lower bound and the algorithm’s upper bound meet.
This is the end of the preview. Sign up
access the rest of the document.