Binary Search Flashcards

Learn all about searching and sorting algorithms in C++

1
Q

Step 1

A

Read the search element from the user

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

Step 2

A

Find the middle element in the sorted list

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

Step 3

A

Compare, the search element with the middle element in the sorted list.

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

Step 4

A

“If both are matching, then display ““Given element found!!!”” and terminate the function”

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

Step 5

A

If both are not matching, then check whether the search element is smaller or larger than middle element.

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

Step 6

A

If the search element is smaller than middle element, then repeat steps 2, 3, 4 and 5 for the left sub-list of the middle element.

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

Step 7

A

If the search element is larger than middle element, then repeat steps 2, 3, 4 and 5 for the right sub-list of the middle element.

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

Step 8

A

Repeat the same process until we find the search element in the list or until sub-list contains only one element.

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

Step 9

A

“If that element also doesn’t match with the search element, then display ““Element not found in the list!!!”” and terminate the function.”

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