Hence ppp 1v b p6p 19 512 15p 521 we can

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t follows that each leaf node can hold up to Pleaf = 31 key value/data pointer. 34 Hashing Direct access: Keyi hashing function address(Keyi) O(1) access vs. O(n) O(log2n) O(logmn) Perfect hashing: 1-to-1 function 35 Hashing Hashing differs from indexing in two important ways: the addresses generated by Hashing appear to be random, i.e. no immediately obvious connection between the key and the location of the corresponding record. Hashing Randomizing different keys may be transformed to the same address (collision) h(ki) = h(kj) => Degrade search speed 36 Hashing design issue Spread out the record need to find a hashing algorithm that distributes records more randomly. Use extra memory Waste space Put more than one record at a single address E.g. record: 80 bytes => create a file with 512-byte physical records i.e. store 6 records at each file address Represent a key a numerical form E.g. LOWELL => 76 79 87 69 76 76 37 represent the key in numerical form If key is a character string, then use a dense mapping or the ASCII values If the keys are only uppercase letters, then map the letters to the range 0-25. take the result sequence as a base 26 value. Example: Numeric_value =0; For ( i=0; i< length_of_key; i++) Numeric_value = Numeric_value*26 + lettervalue(key[i]); Use the bit value of the characters as integer values. Example: convert last 2 cha...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online