Searching Flashcards

1
Q

What are the 2 main algorithms used for searching?

A

Linear and binary searches.

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

Which type of search would be more efficient at searching for an item in a large list?

A

A binary search would be quicker.

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

Which type of search would be used on an unordered list?

A

A linear search can be used on an unordered list.

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

What are the advantages of a linear search?

A

The advantages of a linear search are that it works on any list, as the list does not have to be ordered. Also, it is simpler to code than a binary search.

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

What are the disadvantages of a binary search?

A

The drawbacks of a binary search is that binary searches only work on ordered lists,

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

In this list, how many checks would it take to find the word Tuna if you used a binary search?
Ham, Cheese, Chicken, Tomato, Tuna, Jam, Peanut Butter.

A

3 checks.

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

Using the same list, how many checks would it take for a linear search to find the word Tomato?
Ham, Cheese, Chicken, Tomato, Tuna, Jam, Peanut Butter.

A

4 checks.

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

In this list, which searching algorithm would find the word Gerbil quicker?
Rabbit, Guinea Pig, Dog, Parrot, Cat, Snake, Lizard, Gerbil, Hamster, Fish,

A

A binary search.

A linear search would take 8 checks, whereas a binary search would take only 2 checks

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

What are the advantages of a binary search?

A

The advantages are that a binary search is much more efficient than a linear search when searching for an item within a large list. Also, binary search takes much fewer steps to find an item. For example, a binary search would take a maximum of eight loops to find an item with 1000 items.

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

What are the disadvantages of a linear search?

A

The disadvantages are that a linear search is that it takes much longer with a large list than a binary search, because it has to check each item 1 by 1. Also, if he required item is at the end of the list, the search has to go through all the items until it gets to the required item.

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