Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question
Use the hashing formula to calculate the hash of all the following strings. Use the Python Shell (the
bottom area of Thonny) to help you calculate these numbers, since they get very large, very fast!
A with a base of (11) and a hash size of (100):
AB with a base of 11 and a hash size of 100:
ABC with a base of 11 and a hash size of 100:
ABC with a base of 33 and a hash size of 10000:
Hello with a base of 31 and a hash size of 1000000000
expand button
Transcribed Image Text:Use the hashing formula to calculate the hash of all the following strings. Use the Python Shell (the bottom area of Thonny) to help you calculate these numbers, since they get very large, very fast! A with a base of (11) and a hash size of (100): AB with a base of 11 and a hash size of 100: ABC with a base of 11 and a hash size of 100: ABC with a base of 33 and a hash size of 10000: Hello with a base of 31 and a hash size of 1000000000
Let's apply this formula to the "CAT" values ([67, 65, 84]) from earlier:
The first (0) element is 67:
=(0+31)**67
=8341295116763783101242214530037512645920899177987598203537434247253767513206111213488516390334626911
The second (1) element is 65:
=(1+31)**65
68351585149469122636640694597425667667286544715412888638305331450311031224980497600734786781970432
The third (2) element is 84:
=(2+31)**84
35906324357811432983835510485410216480190897616731123104932324864582947382402655361077065845208720508790429280946504247030088321
Are you seeing how ridiculous big those numbers are? With just a few simple calculations, we're hitting 126 digit numbers! It's gonna get even crazier next,
because now we have to add all those numbers together. In this case, we end up with:
Total Sum 35906324357811432983835510493819863182104149840609978329567263178171133105105666453252805423912799053221520992035755424146685664
Now, the whole goal was to have a short and sweet number. That's where our hash_size parameter comes in. We use modulo to cut it down to a fixed size, say
10**9 (one billion):
=
Total Sum % (10**9)
146685664
That number right there is our hashed value. If we modified the original string even just a little, we'd end up with a wildly different value. And because we're
modulo-ing, we keep things pretty small in the end.
Hashing is powerful, but a little tricky. It's fine if you don't understand it perfectly yet, you'll have plenty of time in the future to understand it better. But for
now, you need to be able to do it by hand!
expand button
Transcribed Image Text:Let's apply this formula to the "CAT" values ([67, 65, 84]) from earlier: The first (0) element is 67: =(0+31)**67 =8341295116763783101242214530037512645920899177987598203537434247253767513206111213488516390334626911 The second (1) element is 65: =(1+31)**65 68351585149469122636640694597425667667286544715412888638305331450311031224980497600734786781970432 The third (2) element is 84: =(2+31)**84 35906324357811432983835510485410216480190897616731123104932324864582947382402655361077065845208720508790429280946504247030088321 Are you seeing how ridiculous big those numbers are? With just a few simple calculations, we're hitting 126 digit numbers! It's gonna get even crazier next, because now we have to add all those numbers together. In this case, we end up with: Total Sum 35906324357811432983835510493819863182104149840609978329567263178171133105105666453252805423912799053221520992035755424146685664 Now, the whole goal was to have a short and sweet number. That's where our hash_size parameter comes in. We use modulo to cut it down to a fixed size, say 10**9 (one billion): = Total Sum % (10**9) 146685664 That number right there is our hashed value. If we modified the original string even just a little, we'd end up with a wildly different value. And because we're modulo-ing, we keep things pretty small in the end. Hashing is powerful, but a little tricky. It's fine if you don't understand it perfectly yet, you'll have plenty of time in the future to understand it better. But for now, you need to be able to do it by hand!
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY