Computer scienceAlgorithms and Data StructuresAlgorithmsArray algorithmsSearch algorithms

Searching problem

Find a card

Report a typo

The process of searching for something is essential and is a part of everyone's daily routine. To find something, we often use the same order of steps as the searching algorithm may use.

Alex is a librarian. He keeps the library cards of members sorted according to their library ID number. A member wants to return a book to the library. Alex has to find the library card of the member. What steps will he follow to find the specific card?

Put the items in the correct order
Read the ID number of the card he wants to find
If no match was found, conclude that the card is not there
Repeat the step above until the card is found or the end of the card pile is reached
Compare: if the card number matches, stop searching. Card found!
If the card number is greater, read the ID of the card on the left.
If the card number is lower, read the ID of the card on the right.
Guess a possible position of the card and check the ID of that card
___

Create a free account to access the full topic