Data Str &amp; Algorithm HW Solutions 74

# Data Str &amp;amp; Algorithm HW Solutions 74 - 74 Chap. 11...

This preview shows page 1. Sign up to view the full content.

74 Chap. 11 Graphs 23456 11013126 2 2 351 61 2 3 8 15 15 41 1 1 0 53 11.16 The problem is that each entry of the array is set independently, forcing pro- cessing of the adjacency list repeatedly from the beginning. This illustrates the dangers involved in thoughtlessly using an inef f cient access member to a data structure implementation. A better solution is to process the actual edges within the graph. In other words, for each vertex, visit its adjacency list. Set the shortest-paths array by setting the values associated with that edge. If the array is initialized with values of , then any vertices not connected by an edge will retain that value. 11.17 Clearly the algorithm requires at least Ω( n 2 ) time since this much informa- tion must be produced in the end. A stronger lower bound is dif f cult to obtain, and certainly beyond the ability of students at this level. The primary goal of this exercise is for the students to demonstrate understanding of the concept of a lower bound on a problem, in a context where they will not be able to make the lower bound and the algorithm’s upper bound meet.
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online