2
$\begingroup$

In "Introduction to Algorithms" by C. E. Leiserson, R. L. Rivest and C. Stein (ISBN: 978-0262033848), p. 264 they state this:

enter image description here

I get everything but the last part stating $h(k) = 67$

>>> r = 17612864
>>> bin(r) # r's binary representation
'0b1000011001100000001000000'
>>> int(bin(r)[: 14 + 2], 2) # extract 14 most significant bits and convert to int
8600
$\endgroup$
3
$\begingroup$

You haven't extracted the 14 most significant bits. First, you have to write $r$ as a $w$-bit number: $$ 00000001000011001100000001000000 $$ Now you extract the 14 most significant bits: $$ 00000001000011 $$ Converting to decimal, this is 67.

$\endgroup$
  • $\begingroup$ Makes sense, I had forgotten about this step thanks $\endgroup$ – ted Apr 7 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.