Chapter5.pdf

# Averages 4 passes through the collision loop each

• 86

This preview shows page 71 - 78 out of 86 pages.

Averages 4 passes through the collision loop Each pass through the collision loop Insert makes 1 access to fetch data[ip] Total for insert: m + 2 + 4 = m + 6 accesses Fetch and Delete make 2 accesses each One to fetch data[ip] , and one to fetch the node’s key Total for Insert or Delete: m + 2 + 8 = m + 10 accesses

Subscribe to view the full document.

72 A Possible Speed Problem With The LQHashed Structure’s Fetch and Delete Develops when lots of nodes have been deleted Leaves the structure with most of the array storing the dummy node’s address, v 2 Gives the appearance of long collision paths ( Fetch and Delete do not terminate on a v 2 reference) Remedy: total the number of v 2 references in the structure (or search length), when excessive Suspend operations and reinsert all nodes into a new initialized array Remedy Algorithm
73 Algorithm to Remedy the LQHashed Structure’s Fetch and Delete Speed Problem 1. temp = data; // set temp referencing primary storage 2. data = new Listing[N]; // allocate a new array data 3. for ( int i = 0; i < N; i++) 4. { if (temp[i] != null && temp[i] != v2) 5. insert(temp[i]); // insert nodes into array data 6. } 7. V2count = 0; // no dummy node references in the array 8. temp = null ; // recycle the old array 9. // end of delete problem remedy

Subscribe to view the full document.

74 Density Of The LQHashed Structure Density = information bytes / total bytes Information bytes = n * w n is the number of nodes, w is the bytes per node Overhead = 4N N is the array size, 4 bytes per array element Density = n * w / (n * w + 4N) = 1 / (1 + 4 N/(n*w)) = 1 / ( 1 + 4 / (l*w)) l = n/N is the Loading Factor Density = 1 / ( 1 + 5.33 / w) for l ≈ 0.75 Density > 0.8 for node widths > 23 bytes per node