Data Structures &amp; Alogs HW_Part_24

# Data Structures & Alogs HW_Part_24 - 93 (b) Fill an...

This preview shows pages 1–3. Sign up to view the full content.

93 (b) Fill an array with 2 n +1 elements, which forces a f 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 Θ( | 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.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
15 Limits to Computation 15.1 This reduction provides an upper bound of O( n log n ) for the problem of maximum f nding (that is the time for the entire process), and a lower bound of constant time for SORTING (since that is the time spent by Maximum Finding in this process). Neither bound is particularly enlightening. There is no true reduction from SORTING to Maximum Finding (in the sense that the transformations do not dominate the cost) since SORTING is an intrinsicly more dif f cult problem than Maximum Finding.
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 10/31/2011 for the course BCN 3431 at University of Florida.

### Page1 / 4

Data Structures & Alogs HW_Part_24 - 93 (b) Fill an...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online