Test #2 Flashcards

(33 cards)

1
Q

Why do we want the initial data of a BST to come in randomly?

A

so the BST fills in instead of becoming a linked list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an AVL tree?

A

BST that remains balanced upon insertion or deletion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does AVL stand for?

A

Adelson, Velskii, and Landis whom are the inventors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why do we want to balance a tree?

A

peak efficiency: makes O(log n) instead of worst case being O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a splay tree?

A

a BST that moves each node that is accessed into the root node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the word splay mean in general?

A

spead out or scatter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why do we want to splay a tree?

A

because 90% of the accesses of a BT occur on only 10% of the data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the 90/10 rule?

A

When 90% of the accesses of a BST occur on only 10% of the data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

AVL tree vs splay tree uses

A

splay : fast lookup on recently used items
AVL : if lookup is a lot more common than insertion/deletion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Hashing definition

A

technique that maps a key to its corresponding hash value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When and why do we want to use hashing as compared to binary search trees?

A

Best and avg case of O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are some common applications that use hashing?

A

Password verification, part lookup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What constitutes a good hashing function?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a collision?

A

when two keys are hashed to the same location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a perfect hash function?

A

no collisions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Linear probing

A

algorithm looks for the next available slot in the hash table to store the collided key.

17
Q

What is clustering?

18
Q

Quadratic probing

19
Q

Chaining

A

way to handle collisions using an array of pointers out to a linked list of all keys that hash to that location

20
Q

Folding (be able to implement in different ways)

A

when a key which is a string is converted into an integer for hashing

21
Q

What is this?

A

used to reference both the data members and member functions of an object

22
Q

Does this mean the same thing as this does in java?

A

has the same usage however in c++ it is a pointer, so u must de reference

23
Q

The differences between structs and unions

A

Unions only hold one active value

24
Q

What are the advantages of unions?

A

memory efficiency since only one field contains data at a time

25
What is a variant record and why is it used?
record type that can have different sets of fields. example: personnel with names, integers for ids
26
What is namespace scope?
provides a scope to the identifiers. used to prevent name collisions
27
Why do you need the using directive with a given namespace?
using provides access to all namespace qualifiers and the scope operator
28
What scope do cin and cout belong to?
std
29
Balanced BST vs Hashing ( BST )
built using dynamic memory worst/average case runtime to insert or search for n items: O n log n can easily obtain a sorted listing of all elements, find a minimum or maximum, or search for a range of values
30
Balanced BST vs Hashing ( Hashing )
fixed overhead for array representing table worst case runtime to insert or search for n items is O n^2 avg case run time is O(1) for searches/insertions cannot get a sorted list or find the minimum or maximum element
31
what happens when you declare a class inside another class as a friend?
Classes declared as friends to any other class will have all the member functions as friend functions to the friend class
32
33
Secondary Clustering
Unable to add an element in quadratic probing because the index calculated is never empty