Hacks

Question 1

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

{ if(isRaining){ day --> "cold" } if(isCold){ day --> "cold" } }

Question 2

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

import random

def turn(): max = 0 for i in range(4): start = random.randint(1, 10) if start > max: max = max print(max)

turn() turn()

Question 3

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

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

Question 4

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

Question 5

You would start your search for element 69 by looking at the middle index, 5, first (4.5, round up to 5). That is six. Six being less than 69 would lead you to consider the more than half. The middle index for this section is 7 (5+9 = 14/2 = 7). Index number seven is 11, which is lower than index number 69. The eighth index is next examined ((8+8)/2 = 8). We searched and discovered the right number since 8 = 69.

Question 6

(8+1)/2 = 4.5 -> lst[5] = 6

(5+8)/2 = 12.5 -> lst[13] = 11

(8+8)/2 = 8 -> lst[8] =69

Question 7

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

To place them in alphabetical order, ascending, you may add these in this sequence. As numbers are bigger, you may compare which numerical value of these ascii characters is greater, allowing these to be appropriately compared.

Question 8

Due to the fact that binary search automatically filters out half of the options with each iteration, it is much faster than sequential search. Since you begin at the center index, you can either select the group that is higher or lower than the middle index. As a result, each time you make a cut, you will eliminate half of the potential outcomes.

Question 9

I would look for number 36 out of the list [64,36,16,11,9]. First, I would choose the middle element ((1+5)/2 = 3, which is the middle element for collegeboard purposes), and since 16 is less than 36, I would shift back (as the list is reversed). As a result, I would choose the second element (1+3/2 = 2), which equals 36, therefore it would take me two tries to reach 36.