Test #2 Flashcards
(33 cards)
Why do we want the initial data of a BST to come in randomly?
so the BST fills in instead of becoming a linked list
What is an AVL tree?
BST that remains balanced upon insertion or deletion
What does AVL stand for?
Adelson, Velskii, and Landis whom are the inventors
Why do we want to balance a tree?
peak efficiency: makes O(log n) instead of worst case being O(n)
What is a splay tree?
a BST that moves each node that is accessed into the root node
What does the word splay mean in general?
spead out or scatter
Why do we want to splay a tree?
because 90% of the accesses of a BT occur on only 10% of the data.
What is the 90/10 rule?
When 90% of the accesses of a BST occur on only 10% of the data
AVL tree vs splay tree uses
splay : fast lookup on recently used items
AVL : if lookup is a lot more common than insertion/deletion
Hashing definition
technique that maps a key to its corresponding hash value
When and why do we want to use hashing as compared to binary search trees?
Best and avg case of O(1)
What are some common applications that use hashing?
Password verification, part lookup
What constitutes a good hashing function?
Load Factor (% of slots in use) is kept under 50% to minimize collisions and to have more wiggle room. Once 50% is reached, double size of table and rehash.
What is a collision?
when two keys are hashed to the same location
What is a perfect hash function?
no collisions
Linear probing
algorithm looks for the next available slot in the hash table to store the collided key.
What is clustering?
Quadratic probing
Chaining
way to handle collisions using an array of pointers out to a linked list of all keys that hash to that location
Folding (be able to implement in different ways)
when a key which is a string is converted into an integer for hashing
What is this?
used to reference both the data members and member functions of an object
Does this mean the same thing as this does in java?
has the same usage however in c++ it is a pointer, so u must de reference
The differences between structs and unions
Unions only hold one active value
What are the advantages of unions?
memory efficiency since only one field contains data at a time