Question: Complete the MIPs code in the attached hash.s so that it implements the function given below. Note that in the example attached as a PDF

 Complete the MIPs code in the attached hash.s so that it

Complete the MIPs code in the attached hash.s so that it implements the function given below. Note that in the example attached as a PDF which walks through the hashing for loop, the string "HAT" is hashed using M = 101 to get a hash value of 86. You can think of the string "HAT" as being expressed in base 31, so that the calculation is 'H' * 31^2 + 'A' * 31^1 + 'T' * 31^0 = 71, 291. Also, note that if 31 in the expression above is replaced with x, we have the form Hx^2 + Ax^+ T, a polynomial. The function below evaluates the polynomial, but uses Horner's Method to reduce the number of multiplications. Thus, a poly such as 67x^2 + 65 x^2 + 66, could be represented as (x(x(67) + 65) + 66. This looks a the code segment: (x*h + v[i]), where each character in v[i] is part of a string; HAT = 67, 65, 66. The function to implement is below. For this project, use M = 104729. The hash value of "joe" shown should be: 679 int hash (char *v, int M) {int h = 0, x = 31; while (*v! = '\0') {h = (x*h + *v) % M; v++;} return h;} Write MIPS code that uses a MIPS function (jal/jr) that will: 1) Prompt the user to input a file name 2) Read the file into memory 3) Convert the file into an integer using the above hash function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!