90 likes | 201 Vues
Treaps and a DVD Checkout System. Jim Moiani Michael Crocker. It’s a tree… it’s a heap…. A treap is a balanced binary search tree It’s node is similar to a binary search tree’s node (has pointer to left and right, and a key) Also contains a random priority
E N D
Treaps and a DVD Checkout System Jim Moiani Michael Crocker
It’s a tree… it’s a heap… • A treap is a balanced binary search tree • It’s node is similar to a binary search tree’s node (has pointer to left and right, and a key) • Also contains a random priority • Since the priorities are randomly assigned, nodes can be inserted like they would for a binary search tree, and then rotated so that the priorities of the nodes also maintain the properties of a heap
What do you use it for? • We used treaps to create a DVD rental system • Separate treaps for in-stock movies, checked-out movies, and a record of the membership • Features include ability to add new movies and members, display a member’s records, and check movies in and out
So what are the benefits? • Provides all the functionality of binary search trees, like inorder traversal, but also guarantees a Θ(lg n) search time • Of course, this is given that you’ve made enough insertions so that the priorities approach a normal distribution
What’s left to add? Possible Improvements • A GUI • Provides overdue notification; could interface with a member account system (debit credit cards for overdue movies?) • A few member functions work by entering the member number; could interface with a scanner • More info for DVDs, like UPC, release date, review notes, and other information
And one more… • More treaps which are pointers to our member classes, which can be referenced to sort and display other categories quickly and easily • Sort DVDs by rating, release year, title, and so on… • Sort members by name, location, member number • All without searching the whole treap!