Question: ( 1 0 Points ) Read a file and hash the words: Read a text file ( there are several named in the table below
Points Read a file and hash the words:
Read a text file there are several named in the table below and posted on
Canvas and hash the words using the suggested hash function from Levitin,
page :
h ; for i to s do h h C ordci mod m
where:
h is the computed hash value,
s is the length of the word being hashed,
ci is the ith character of the word,
ordc is the numerical value of character c in the alphabet in use,
C is a constant larger than every ordci and
m is the modulus defining the size of our hash table.
We will take ordc to be the ASCII value of the characters in each word. Thus,
ordc in for c in A B Z a b z
respectively. All other characters are discarded; we define words as unbroken
sequences strings of consecutive alphabetic characters, both upper and lower
case, plus apostrophes and hyphens in the lines read for the file. Java uses
Unicode, but ASCII is still under there somewhereyou just need to dig it out.
Well start simply with TheRavenBtxt text file, and we will take C
and m even though its not prime. These represent parameters that
can be changed to alter the shape and composition of our resulting hash table.
Well increase the size of our table when we use the appended files.
You are free to experiment with changing these parameters on your own, of
course!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
