u4 Flashcards

1
Q

median of a list of n numbers

A

can be found by sorting the listand picking the middle value if nis odd or calculating the mean of the two middle values if nis even

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

Hashing

A
  • Data items are placed in a series of indexed slots in a linear structure called a hash table.
  • The ratio of the number of occupied slots to the size of the table is known as the load factor.
  • The mapping of an item to a slot index is performed by means of a hash function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The folding method

A

Divide the digits of the item into equal size pieces (except possibly the last). Then, add the pieces together and take the remainder when the total is divided by the number of slots.

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

The mid-square method

A

Square the item. Then, extract the middle digit or middle two digits, depending on whether the number of digits of the squared item is odd or even.Finally, take the remainder when this number is dividedby the number of slots.

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

open addressing

A

if a collision occurs, the item is placed in another slot

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

Linear probing

A

searches sequentially for the next open slot

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

Quadratic probing

A

avoids clustering by adding successive square numbers to the index

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

chaining

A

each slot may contain a collection of items, all having the same hash value

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

Binary search trees

A

A binary tree (not necessarily complete), such that for every node p, all the keys within p’s left subtree are less than the key of p; and all the keys withinp’s right subtree are greater than the key of p.

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

Insert to BST

A
  • If the tree is empty, replace it with a tree consisting of a single node with the new key.
  • Otherwise, if the new key is less than the key of the root, then insert into the left subtree of the root, else insert into the right subtree of the root.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Delete from BST

A
  • Find the node N to be deleted.
  • If N has no children, remove it.
  • If N has one child, replace N with the child.
  • If N has two children, find N’s successor, M, in N’s right subtree. M is a leaf. Replace N’s content with M’s content and delete M.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

AVL trees

A

A self-balancing binary search tree.

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

height of a tree

A

number of edges on the longest path from the tree’s root to a leaf, if the tree is non-empty, and −1 otherwise.

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

A balanced BST

A

a BST for which the difference in height between any node’s left and right subtree doesn’t exceed 1.

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

balance factor

A

calculated by subtracting the height of the node’s right subtree from the height of its left subtree

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