1. if-else statement

stayInside = True
isCold = True
isRaining = True

if isCold or isRaining:
    stayInside = True
else:
    stayInside = False

2. turn-based algorithm

import random

attempts = 4
score = []
length = len(score)

while attempts > 0:
    score.append(random.randint(1,10))
    attempts -= 1

score.sort()

print(score[len(score) - 1])
print(score)
9
[3, 4, 7, 9]

3. Reach the grey square

{
if CANMOVEFORWARD{
    moveForwards
}
else{
    if CANTURNRIGHT{
        turnright
    }
    if CANTURNLEFT{
        turnleft
    }
}
}

4. Binary search tree

images

5. how to get 69

Check the number splitting the array, if this number is less than the desired number take the number splitting the larger numbers, repeat until desired number is found.

6. How I found the list

images

7. put list in order

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

You could add this in this order in order to put them in alphabetical order, ascending. This way these could be properly compared, as numbers are greater, you can compare which numerical value of these ascii characters is greater.

8. why Binary > Sequential

Binary search is far quicker than sequential search because binary search inherently rules 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.

Out of the list [64,36,16,11,9], I would be searching for 36. First I would select the middle element ((1+5)/2 = 3, and for the purpose of collegeboard that is the middle element), and 16 is less than 36, so I would move back, (as the list is reversed). Hence, I would select the 2nd element ((1+3)/2 = 2) and that is equal to 36, so it would take me two tries in order to get to 36.

images