Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
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
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 MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
Step by stepSolved in 2 steps
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
It says every answer is wrong, I am still unsure how to solve the problems.
Solution
Bartleby Expert
by Bartleby Expert
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
It says every answer is wrong, I am still unsure how to solve the problems.
Solution
Bartleby Expert
by Bartleby Expert
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- for (String name : likedBy) { String likedUser= name.trim(); Set<String> likes = likesMap.getOrDefault(likedUser, new HashSet<>()); Here you create a new Set for likes. This is in the iteration over the likers though so it results in many missing entries. [ How do i Fix this ] import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; public class FacebookLikeManager { private Map<String, Set<String>> likesMap; public FacebookLikeManager() { likesMap = new HashMap<>(); } public void buildMap(String filePath) { try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { String line = reader.readLine(); while (line != null) { String[]...arrow_forwardThis question is for Java, and in the picture provided.arrow_forwardA tuple that contains elements is true. True or false? In Python.arrow_forward
- Write a Python program to print a hollow square pattern of stars (*) with a hash (#) symbol at the center of the square. The side length n of the square shall be entered by the user as an odd integer number greater than 4.arrow_forwardneed code for this in python or java thanksarrow_forwardUse 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 1000000000arrow_forward
- In python: student_dict is a dictionary with students' name and pedometer reading pairs. A new student is read from input and added into student_dict. For each student in student_dict, output the student's name, followed by "'s pedometer reading: ", and the student's pedometer reading. Then, assign average_value with the average of all the pedometer readings in student_dict..arrow_forwardHere is the code I am using. It is almost correct. Can you please help me figure this out please? Below is my code as well as the incorrect output: import random # Functions for generating lottery numbers, counting matches, and simulating plays def generate_lottery_numbers(): """ Generates a list of 5 random integers between 1 and 42, inclusive, with no duplicates. Returns: list: A list of lottery numbers """ return random.sample(range(1, 43), 5) def count_matches(my_list, lottery_list): """ Takes two lists of equal length representing the player’s chosen number list and the generated lottery list and returns the number of matches between my_list and lottery_list. For example, count_matches([10, 6, 20, 5, 7], [30, 6, 7, 40, 5]) will return 3, since both lists contain 5, 6, 7. Parameters: my_list (list): Your lottery numbers. lottery_list (list): A list of the winning numbers. Returns: int: The number of matching integers """ return len(set(my_list) & set(lottery_list))...arrow_forwardI need help on this python assignment.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education