{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hmwk_5_sol

# hmwk_5_sol - Discrete Structures Assignment 5 Due at...

This preview shows pages 1–2. Sign up to view the full content.

Discrete Structures Sept 26 2011 Assignment 5: Due at beginning of class Monday, Oct 3rd Prof. Hopcroft *******Note: this homework is subject to the style guide on the website. Points will be deducted for homeworks not following the guidelines.******** *******Please print out and staple the grade sheet to the back of your homework!****** **********Remember Midterm this Friday! We consider this homework to be a good review.********** 1. Describe a method to store a set whose elements can be any 20-digit integer. Describe how someone using your solution can check whether or not a new element is in the set in constant time (see definitions on course website for explanation of constant time). Hint: your solution will need to deal with the possibility of collisions. Solution: The solution is to use hashing with linear probing or with linked lists. A description of hashing can be found: http://www.cs.cornell.edu/courses/CS2800/2011fa/Lectures/lec sept 21.pdf Special attention was paid to the size of the hashing array, as that is what makes hashing work. Without a correct or manageble array size, the rest of hashing does not work. 2. I wish to calculate mod 9 for very large numbers (e.g. 4756213912 mod 9). Prove that I can get the correct answer by adding the digits of the large number and taking the result mod 9. That is to say,

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}