Access over 20 million homework & study documents

Midterm 2 examples with solutions

Content type
User Generated
School
University of Texas at San Antonio
Rating
Showing Page:
1/5

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/5

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/5

Sign up to view the full document!

lock_open Sign Up
Showing Page:
4/5

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 5 pages?
Access Now
Unformatted Attachment Preview
CS3343 Analysis of Algorithms Some problems with solution 1. Hash Table Probabilities (1) (1 point) Suppose 2 keys are inserted into an empty hash table with m slots. Assuming simple uniform hashing, what is the probability of: (a) exactly 0 collisions occurring Solution: m−1 m (b) exactly 1 collisions occurring Solution: 1 m (2) (2 points) Suppose 3 keys are inserted into an empty hash table with m slots. Assuming simple uniform hashing, what is the probability of: (a) exactly 0 collisions occurring Solution: (m−1)(m−2) m2 (b) exactly 1 collisions occurring Solution: m−1 + m−1 + m−1 = 3 m−1 m2 m2 m2 m2 (c) exactly 2 collisions occurring Solution: 1 m2 2. Red-Black Trees (1) Company X has created a new variant on red-black trees which also uses blue as a color for the nodes. They call these “red-black-blue trees”. Below are the new rules for these trees: • • • • • • Every node is red, blue, or black. The root is black. Every leaf (NIL) is black. If a node is red, then both its children are black. If a node is blue, then both its children are red or black. For each node, all simple paths from the node to descendant leaves contain the same number of black nodes. (a) (2 points) In class we found that the height, h, of a red-black tree is ≤ 2 log2 (n + 1) (where n is the number of keys). Find and prove that a similar bound on height of the red-black-blue trees. (Hint: You can use the same approach as we did to show h ≤ 2 log2 (n + 1)). So ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Goes above and beyond expectations!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4