Search Algorithms Flashcards

1
Q

What is a search algorithm (1)

A

1.) An algorithm used to find an item with certain characteristics in a list or collection of items.

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

Linear/Sequential Search (4)

A
  1. ) Brute force strategy.
  2. ) Does not require a sorted list.
  3. ) Moves sequentially through the list until the item is found.
  4. ) For (lists > 8) Binary search is more efficient.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Linear/Sequential | Big O (3)

A
  1. ) Best: O(1)
  2. ) Worst: O(n)
  3. ) Average: O( (n+1)/(k+1) )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Binary/Half-interval Search (2)

A
  1. ) Divide and conquer.

2. ) Requires sorted list.

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

Binary Search | How (3)

A
  1. ) Compare element with middle element of list.
  2. ) Discard half which does not contain element
  3. ) Repeat until found.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Binary | Big O (2)

A
  1. ) Best: O(1)

2. ) Worst/Average: O( log2(n) )

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