Reducing signed hash codes to array indices

A storage component uses range reduction, the conversion of an integer hash code into a valid array index. Its eight permitted indices are 0 through 7. For a hash code cc, it calculates


r=c−8⌊c8⌋.r=c-8\left\lfloor\frac{c}{8}\right\rfloor.


The floor function is denoted by ⌊ ⌋\lfloor\ \rfloor. Complete the table with the floor value and resulting index for each supplied hash code. Enter exact integers.

Hash code cfloor(c/8)Index r
-17
-1
18
41

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Hash Codes and Hash Functions Questions: