searching Flashcards

1
Q

linear search

A

checks each item of the list systematically to see if it matches the key - O(n)

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

expected values

A

the sum of each potential outcome multiplied by its probability:
x1P(X=x1) + x2(P(X=x2) + … + xn*P(X=xn)

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

sorted linear search

A

if list sorted in ascending order search can be stopped once an element is reached that is larger than the key

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

binary search

A

divide and conquer - calculates mid point of sorted list, if mid point greater than search term discard mid point + if smaller discard mid point -, repeat until key is mid point or no items remain - O(log(n))

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

SCAN

A

o(n^2) - for each element all other elements are checked to see if they are equal

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

STOR

A

o(n) - loops through once, in a second array the value of the element is used as the key to a second array, that index incremented, if any index > 1 duplicates occur - second array, must have length greater than largest value of first array, and first array must only contain ints

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

interpolation search

A

like binary search but uses weighted guess for midpoint - midpoint calculated by [(key - a[i])/(a[j]-a[i]) * j - i]

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