1 / 13

This is a title

This is a title. Titles make PowerPoint happy. Up-Trees. (not as much work as it looks) Perform Disjoint Union-Find operations on Up-Tree with path compression and using weight (# of nodes) in merges. Starting with empty tree.

joshuaross
Download Presentation

This is a title

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. This is a title Titles make PowerPoint happy.

  2. Up-Trees • (not as much work as it looks) • Perform Disjoint Union-Find operations on Up-Tree with path compression and using weight (# of nodes) in merges. • Starting with empty tree. • Keep track of (sub)tree weight, and pointers into tree (pointers isn’t too hard) • Vaguely have a sense of # of operations (e.g. edge traversals) • For items: a,b,c,d,e,f,g,h,i,j,k • Union (a,b). Union (b,c). Union (d,e). Union (d,f). Union (d,j). Union (d,k). Union (e,g). Union (h,i). Union (c,h). Union (c,f). Find (i). Find (b). Find (c). Find (i). Find (h).

  3. Make a nicely-connected Maze • (diagram on next page) • Make a random 3x3 maze with exactly one path between any two points • Simulate up-trees (or don’t if you feel comfortable) • Use edge order (first edge, second edge,…) on next page. • Feel the power of the Dark Side

  4. Order of edges:

  5. BTW • Show that -notation is an equivalence relation. Formal proofs not necessary. • Contemplate putting functions into up-trees based on -notation (but not for too long…)

  6. Hashing functions • Hash table size 7, key=integers • Consider this hashing function: • H(X)= X mod 7 • What patterns of (distinct) keys would cause only one bucket to be used? • (answer on next page)

  7. Hashing functions cont’d • One answer: 0,7,14,21,28,… Integers may have a reason to be multiples of 7 (probably even worse if you’re hashing strings of English words – very biased data)

  8. Hashing functions… • How about this hashing function: • given a parameters A,B,K: • HA,B,K(X)=(A*X+B mod 7K)/K • What patterns would cause only one bucket to be used? • For a given bad pattern, can you find different values of A,B,K to make this pattern OK (defeat your adversary)? • Given a patterns, if you ran your program many times with random A,B,K, what’s the average performance? • If you knew the data ahead of time, how could you design a really good hashing function?

  9. Extendible Hashing • In the extendible hash table on the next page, perform the following inserts:01000101

  10. Extendible Hashing: table so far… 0001 0110 0111 1000 1010 1001 1111 1100 Note: Buckets can store up to 3 keys before overflowing

  11. Binomial Queues • Merge these binomial queues: From Introduction to Algorithms, Cormen et. al, pp 410-411.

  12. Tricks & Leaps with Treaps • What happens when you insert this into a BST: 1,2,3,4,5,… • What about a treap? • Create a sequence of random numbers that’d create a perfectly balanced Treap for 1,2,3,4,5… • What should the range of your random priorities be? What are bad properties for the random-number generator?

  13. Traverse & not-too Deep: Treaps • Insert key 18 with random priority 2 into this Treap (don’t worry about “proper” way to rotate):

More Related