Searching Flashcards

1
Q

What is a sequential search?

A

A sequential search is an algorithm that checks each element of a list or array in order until the desired element is found or the list ends.

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

True or False: A sequential search can be used on both sorted and unsorted lists.

A

True

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

Fill in the blank: In a sequential search, the search starts from the ________ of the list.

A

beginning

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

Which of the following is an advantage of sequential search? (A) It is faster than binary search. (B) It can be used on unsorted data. (C) It requires less memory.

A

B) It can be used on unsorted data.

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

What type of data structure is typically used for a sequential search?

A

An array or a list.

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

True or False: A sequential search is more efficient than binary search for large datasets.

A

False

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

What is the best-case time complexity of a sequential search?

A

When the desired element is the first element in the list.

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

In which scenario would a sequential search be preferred over other search algorithms?

A

When dealing with small datasets or unsorted lists.

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

What is the primary limitation of sequential search?

A

Its inefficiency for large datasets compared to more advanced searching algorithms.

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

What is the primary purpose of a sequential search?

A

To find a specific item within a list or array by checking each element in order.

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

True or False: A sequential search can be performed on a sorted list more efficiently than on an unsorted list.

A

False

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

Which of the following scenarios is best suited for a sequential search? A) Searching in a large database B) Searching in a small, unsorted list C) Searching in a sorted array

A

B) Searching in a small, unsorted list

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

What is a key disadvantage of using a sequential search compared to other search algorithms?

A

It can be inefficient for large datasets as it may require examining every element.

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

What is the primary purpose of a sequential search?

A

To find a specific value in a list or array.

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

True or False: A sequential search is more efficient on a sorted array than on an unsorted array.

A

False.

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

Fill in the blank: A sequential search examines each element in the array in _____ order.

17
Q

What is the first step in performing a sequential search on a sorted array?

A

Start at the first element of the array.

18
Q

Which of the following is a key characteristic of a sequential search? (A) Requires the array to be sorted (B) Can be used on any type of list (C) Has a logarithmic time complexity

A

B) Can be used on any type of list.

19
Q

True or False: A sequential search can be optimized by skipping elements in a sorted array.

20
Q

What happens if the target value is not found during a sequential search?

A

The search will complete after checking all elements and indicate that the value is not present.

21
Q

What type of search algorithm is a sequential search?

A

It is a linear search algorithm.

22
Q

What is the primary purpose of binary search?

A

To efficiently find the position of a target value within a sorted array.

23
Q

True or False: Binary search can be performed on unsorted arrays.

24
Q

What condition must be satisfied for binary search to work?

A

The array must be sorted.

25
Which of the following is a key step in the binary search algorithm? (a) Compare the target value to the middle element, (b) Sort the array, (c) Traverse the entire array
a) Compare the target value to the middle element.
26
Short Answer: What happens to the search space after each comparison in binary search?
The search space is halved.
27
True or False: Binary search requires additional space for its operation.
False
28
Fill in the blank: In binary search, if the target is less than the middle element, the search continues in the ______ half.
left
29
Multiple choice: Which of the following algorithms is more efficient for searching in a sorted list? (a) Linear search, (b) Binary search
b) Binary search