5.2 SEARCHING ALGORITHMS - (Section 5 - Algorithms) Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

There are two types of search algorithms. What are they?

A
  • Linear search
  • Binary search
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a linear search?

A

When data is unsorted, the only sensible option is to start at the beginning and search every item until you find the one.

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

Advantages of linear search.

A
  • very fast on small to medium lists (efficient)
  • list does not need to be sorted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Disadvantages of linear search.

A
  • ## very slow for large amounts of data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is binary search?

A

Finding an item in a sorted list by dividing the list each time and comparing the desired item to the divided list.

If the length of the list is an even number than half of that number is the midpoint.
For example, if the list has 8 items in it than the 4th items is considered the midpoint.

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

Advantages of Binary search.

A
  • Much quicker than linear search (especially in large data sets/lists)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Disavdantages of Binary search.

A
  • ## List must be sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Disavdantages of Binary search.

A
  • ## List must be sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What type of algorithm is a binary search.

A

Divide and Conquer.

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