Search algorithms Flashcards

(12 cards)

1
Q

What is a syntax error?

A

• An error that breaks the rules of the language
• The program will not run

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

What is a logic error?

A

• An error that gives the wrong result
• The program can still run

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

What is a searching algorithm?

A

• An algorithm used to find a target value in a list

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

What is linear search?

A

• A search that checks each item one by one

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

What type of list can linear search be used on?

A

• Any list
• Sorted or unsorted

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

What are the advantages of linear search?

A

• Easy to write
• Works on unsorted data

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

What is the main disadvantage of linear search?

A

• It is slow on large lists

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

What is binary search?

A

• A search that repeatedly checks the middle of a sorted list

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

What must be true before binary search can be used?

A

• The list must be sorted

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

Why is binary search faster than linear search?

A

• It halves the list each step

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

What are the disadvantages of binary search?

A

• More complex
• Only works on sorted data

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

What does ‘divide and conquer’ mean in binary search?

A

• The list is split in half each step

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