{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Data Str &amp; Algorithm HW Solutions 93

# Data Str &amp; Algorithm HW Solutions 93 - Θ | V | | E...

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

93 (b) Fill an array with 2 n + 1 elements, which forces a fi nal growth to an array of size 2 n +1 . Now, do an arbitrarily long series of alternating inserts and deletes. This will cause the array to repeatedly shrink and grow, for bad ( Θ( n 2 ) ) performance. (c) If we shrink the array whenever the space use goes below 25%, we will have the desired performance. 14.17 Each node can be visited only once. Thus, there is initially potential for | V | node visits. We can look at each edge only once (the edges out of a node are visited when the node is visited). Thus, there is potential for | E | edge visits. The initial call to DFS can expend a small part of that potential, or a large part. But, the sum of all the calls to DFS must cost
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Θ( | V | + | E | ) . 14.18 As with Move-to-Front, the contribution of unsuccessful searches requiring comparisons between keys A and B is independent of other keys. We have an unsuccessful search for A if and only if we have had more requests for B so far. Assuming that B is requested R B times and A is requested R A times with R B > R A , we can only have unsuccessful searches twice the number of times that A is requested. This happens at most for R A requests to B occurring before R A requests to A. The remaining requests to B are successful without encountering A. Thus, the Count heuristic can have cost at most twice that of the optimal static ordering....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online