1.) (Portfolio) Define a pseudocode algorithm that will efficiently play the guessing game.
Choose random integer from 1 to 100
If guess is too low, guess initial guess + 10
Else guess initial guess - 10
If guess is too low, guess last guess + 10
Else guess last guess - 2
If guess is too low, guess last guess + 10
Else guess last guess - 1
2.) (Portfolio) To guess a number between 1 and 100, what's the maximum number of guesses your algorithm would take?
To guess a number between 1 and 100, the maximum number of guesses our algorithm would take is 10 guesses.
3.) (Portfolio) To guess a number between 1 and 500, what's the maximum number of guesses your algorithm would take?
To guess a number between 1 and 500, the maximum number of guesses my algorithm would take is 50 guesses.
4. Suppose you have a deck of cards and you want to find the Ace of Spades. If the deck is shuffled, which is the best search algorithm to use and why?
Answer
The best search algorithm to use is linear because the cards are not ordered, they are shuffled. For this reason, you must check every card to see if it is the correct one.
5. Give an example of a search problem you encounter in everyday life. Do it use sequential, binary, or some other search?
Answer
An example of a search that I do every day is looking for clothing in the pile of clothes on my floor. To solve this, I use sequential search methods by looking at each individual piece of clothing until i find the one that I want.