1

Write this Boolean statement in the form of a conditional (if/else) statement: stayInside⟵((isCold) OR (isRaining))

IF (isCold or isRaining) {
    stayInside  True
}
ELSE {
    stayInside  False
}

2

Create an algorithm that uses selection and/or iteration that will represent one player’s complete turn.

During a turn, each player gets 4 attempts/chances to get the greatest number possible. During each attempt, the player will use a random number generator to select a random number from 1 to 10. After they have had 4 chances, their score is the greatest number they received from the random number generator, and their turn is over.

import random
numAttempts = []

i = 1 
while i <= 4:
    numAttempts.append(random.randint(1,10))
    i = i +1 
    
print("Attempts:", numAttempts)
print ("----------------------------------")
print("Maximum number from player:")
print(max(numAttempts))
Attempts: [9, 2, 9, 4]
----------------------------------
Maximum number from player:
9

3

Create an algorithm that will allow the arrow to reach the gray square:

for x in range(0, 3):
    move forward 
turn right 
for x in range(0, 5):
    move forward 
turn right
for x in range(0, 2):
    move forward 
# it is much more efficient coding wise
{
if CANMOVEFORWARD{
    moveForwards
}
else{
    if CANTURNRIGHT{
        turnright
    }
    if CANTURNLEFT{
        turnleft
    }
}
}

4

Make a binary search tree of different the list [1,2,3,4,6,9,11,69]

See comment for image

5

Explain thoroughly how to find the number 69 in the list above (use key words)

To find 69 using sequential search, the list would be iterated 7 times. Using a binary search instead, this process would be much more efficient. The search would start from the middle index, then going to the first and last index and dividing by two. This process is repeated until the number 69 is found.

6

Make a diagram explaining how you found the list (not tree, include equation)

See comment for image

7

Put this list of strings in a order that can be used for binary search [“store”,”Market”,”Walmart”,Target”,”Ralphs”]

[”Market”,”Walmart”,“store”,Target”,”Ralphs”]

8

Explain why Binary Search is more efficient than Sequential Search

Binary search is more efficient because it moves exponentially while sequential search moves through the list one by one. Binary search takes out half of the possibilities every iteration. Since you start at the middle index, you can either choose to pick the group that is greater than the middle index, or the group that is lower. As a result, you will rule out half of the known possibilities every single time you make a cut.

9

[64,36,16,11,9] Explain which number you are finding, how many check it would take, and make a binary search tree

If I am searching for the number 11, which would take two iterations. You would start at 16, the middle index. Then you would do 3+5/2 to get 4, so the next middle index would be 11, which is the number we want to find.

See comment for image