Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Algorith 3304 ) Let (Algorith 3304 ) Let\'s say that we are using upper-case le

ID: 645286 • Letter: #

Question

(Algorith 3304 ) Let

(Algorith 3304 ) Let's say that we are using upper-case letters as keys in a hash table, and that hash codes are assigned based on each letter's position in the alphabet, so A has the hash code 0, B has the hash code 1, etc. Show what happens when the keys below are inserted into a hash table with 11 buckets, in that order (starting with S), using linear probing to resolve collisions. Show each intermediate form of the hash table as well as the final result. The first two insertions are shown.

Explanation / Answer

key   S     N   I Y   J B   A   G

hash code 18 13 8 24 9   1   0   6

S= 18/11= 7

N=13/11=2

I= 8

Y=24/11=2, it collides with N, hence we place it in the next available location i.e

J=9

B=1

A=0

G=6

  steps  
  1st  
  2nd  
  3rd  
  4th  
  5th  
  6th  
  7th  
  8th  
  10  
       
       
       
       
       
       
       
       
  9  
       
       
       
       
  J  
  J  
  J  
  J  
  8  
       
       
  I  
  I  
  I  
  I  
  I  
  I  
  7  
  S  
  S  
  S  
  S  
  S  
  S  
  S  
  S  
  6  
       
       
       
       
       
       
       
  G  
  5  
       
       
       
       
       
       
       
       
  4  
       
       
       
       
       
       
       
       
  3  
       
       
       
  Y  
  Y  
  Y  
  Y  
  Y  
  2  
       
  N  
  N  
  N  
  N  
  N  
  N  
  N  
  1  
       
       
       
       
       
  B  
  B  
  B  
  0  
       
       
       
       
       
       
  A  
  A