Part 1 - MCQ Grade

To prepare ourselves for the AP Exam coming up, we had to take a College Board Mock MCQ on Wednesday, March 14. On this exam, I got a score of 31/70. This score, as compared to Mr. Lopez’ scale, would earn a 0.8/1.

Results: 2021-Practice-Exam-MCQ.png

That being said, I only finished up to question 42, meaning in actuality I got a 31/42, which would earn me 73.8% raw score.

Part 2 - MCQ Reflection/Correction

Q7 Move piece on game board

Q7.png

Originally I had chosen my answer as B (2 spaces), however I failed to realize that when the icon landed on yellow, it moved onto another yellow position so the counter would have to go up once again. This would mean that the counter would end at a score of 3

Q9 Digital representation of audio signal

Q9.png

Audio isn’t represented as code that gives instruction on how to replicate it. I don’t know what I was thinking when I answered this question as I know already that audio is represented by bits and can’t be represented by instructions.

Q14 Error in isIncreasing procedure

Q14.png

Contrary to my original belief, switching the return booleans will give you a properly working funciton as opposed to an infinite loop.

Q15 Use drawLine procedure to draw figure

Q15.png

As the line is increasing upwards, not sideways, the yVal should be the one increasing each time while the xVal increasingly increasingly as 1. A real in-depth think about the problem would have saved me here

Q18 True statement about the network

Q18.png

I only took into consideration the quickest path from A to D, without realizing that it could’ve taken many paths longer than the immediate path. However if B and F are cut, A cannot reach G

Q23 True statement about the internet

Q23.png

This error was a lack of understanding of the concept of the internet. The internet and the Web are two different things, as the Web is responsible for protocol. However it is household knowledge that the internet can support an increasing number of users, as thats how it functions, and it haas to support billions world-wide

Q33 Efficiency of drivign route algorithms

Q33.png

My incorrect answer came from my lack of understanding of the word “heuristic”. This word means: proceeding to a solution by trial and error or by rules that are only loosely defined. If I had an understanding of this word, I wouldn’t have falsely identified this program as an algorithm

Q34 Error in science simulation

Q34.png

The code segment runs a random number twice so the only way to correct this was to replace the second random decision with an else statement.

Q36 Why information is hard to remove from internet

Q36.png

This question was also answered incorrectly due to a lack of brain-control. I was reluctant to understand that something as simple as a password is what makes information hard to access on the internet. Instead I chose the next-best thing, which would be the amount of data present on the internet, making specific things hard to find, which is inherrently not true anyway.

Q41 Use of crowdsourcing in online games

Q41.png

This was just a misinterpretation of the prompt. Its asking for how to insentivize good behavior as opposed to discouraging bad behavior. I had originally thought this meant the same thing but a software engineer might disagree.

Part 3 - FMQ Hacks

FMQ Hacks

  1. as a popcorn hack (binary challenge), describe an overflow in 8 binary digits
  • 11111111 + 1 = 00000000 and 00000000 - 1 = 11111111
# represent gates and circuits
# as a popcorn hack (coding challenge), create multiple new circuits and gates
# NOT, NAND, NOR, XOR, XNOR
# Create a hypothetical circuit, such as burglar alarm, decision tree for autonomous car, etc.

# OR gate
def OR_gate(A, B):
    return A or B

# AND gate
def AND_gate(A, B):
    return A and B

# NOT gates
def NOT_gate(A):
    return not A

def NAND_gate(A, B):
    return not AND_gate(A, B)

def XOR_gate(A, B):
    return (A and not B) or (not A and B)

def XNOR_gate(A, B):
    return not XOR_gate(A, B)



# Theoritical circuit representing a Car starting
# A and B could be security checks, such as key being inserted or a fob being present
# C and D could be operational checks, such as a start button being pressed and safety belt being fastened
# The enclosing AND gate ensures car only operates when both security and operational checks are met
def circuit(A, B, C, D):
    return AND_gate(OR_gate(A, B), AND_gate(C, D))

# Print truth table for circuit
print('A', 'B', 'C', 'D', "-->", 'Output')
# nesting of loops for both the True, False combination of A, B, C, D 
# this algorithm is 2 ^ 4 = 16, thus producing all 16 combinations 
# each combination terminates with the output of the circuit
for A in [False, True]:
    for B in [False, True]:
        for C in [False, True]:
            for D in [False, True]:
                print(A, B, C, D, "-->", circuit(A, B, C, D))
  1. as a hack (binary challenge), make the rgb standard colors
# Convert binary RGB triplet to decimal
# as a hack (binary challenge), make the rgb standard colors
# as a 2nd hack, make your favorite color pattern 

import matplotlib.pyplot as plt
import matplotlib.patches as patches

# Function to convert binary to decimal
def binary_to_decimal(binary):
    return int(binary, 2)

def plot_colors(rgb_triplets):
    # Create a figure with one subplot per RGB triplet
    fig, axs = plt.subplots(1, len(rgb_triplets), figsize=(2 * len(rgb_triplets), 2))
    
    # Ensure axs is always a list
    axs = axs if len(rgb_triplets) > 1 else [axs]

    for ax, (red_binary, green_binary, blue_binary) in zip(axs, rgb_triplets):
        # Convert to binary strings to decimal
        red_decimal = binary_to_decimal(red_binary)
        green_decimal = binary_to_decimal(green_binary)
        blue_decimal = binary_to_decimal(blue_binary)

        # Normalize number to [0, 1] range, as it is expected by matplotlib 
        red, green, blue = red_decimal/255, green_decimal/255, blue_decimal/255

        # Define a rectangle patch with the binary RGB triplet color and a black border
        rect = patches.Rectangle((0, 0), 1, 1, facecolor=(red, green, blue), edgecolor='black', linewidth=2)
        
        # Add the rectangle to the plot which shows the color 
        ax.add_patch(rect)

        # Remove axis information, we just want to see the color
        ax.axis('off')

        # Print the binary and decimal values
        print("binary:", red_binary, green_binary, blue_binary)    
        print("decimal", red_decimal, green_decimal, blue_decimal)
        print("proportion", red, green, blue)

    # Show the colors
    plt.show()

# Test the function with a list of RGB triplets
rgb_triplet = [('11111111', '11111111', '11110000')] # College Board example
plot_colors(rgb_triplet)

rgb_primary = [('11111111', '00000000', '00000000'), 
                ('00000000', '11111111', '00000000'),
                ('00000000', '00000000', '11111111')]
plot_colors(rgb_primary)
binary: 11111111 11111111 11110000
decimal 255 255 240
proportion 1.0 1.0 0.9411764705882353\



binary: 11111111 00000000 00000000
decimal 255 0 0
proportion 1.0 0.0 0.0
binary: 00000000 11111111 00000000
decimal 0 255 0
proportion 1.0 1.0 0.0
binary: 00000000 00000000 11111111
decimal 0 0 255
proportion 0.0 0.0 1.0
# Big O notation example algorithms
# as a popcorn hack (coding challenge), scale list of size by factor of 10 and measure the times
# what do you think about college board's notion of reasonable time for an algorithm?
# as a 2nd hack, create a slow algorithm and measure its time, which are considered slow algorithms... 
#   O(n^3) which is three nested loops 
#   O(2^n) which is a recursive algorithm with two recursive calls

import time

# O(n) Algorithm that accesses each element in the list twice, 2 * n times 
def algorithm_2n(lst):
    for i in lst:
        pass
    for i in lst:
        pass

# O(n^2) Algorithm that accesses each element in the list n times, n * n times
def algorithm_nSquared(lst):
    for i in lst:
        for j in lst:
            pass

# O(1) Algorithm that accesses only the first 10 elements in the list, 10 * 1 is constant 
def algorithm_10times(lst):
    for i in lst[:10]:
        pass

# Create a large list
n = 100000
lst = list(range(n))

# Measure the time taken by algorithm1
start = time.time()
algorithm_2n(lst)
end = time.time()
print(f"Algorithm 2 * N took {(end - start)*1000:.2f} milliseconds")

# Measure the time taken by algorithm2
start = time.time()
algorithm_nSquared(lst)
end = time.time()
print(f"Algorithm N^2 took {(end - start)*1000:.2f} milliseconds")

# Measure the time taken by algorithm3
start = time.time()
algorithm_10times(lst)
end = time.time()
print(f"Algorithm 10 times took {(end - start)*1000:.2f} milliseconds")
Algorithm 2 * N took 0.22 milliseconds
Algorithm N^2 took 846.18 milliseconds
Algorithm 10 times took 0.03 milliseconds
  1. Error with multiplication using repeated addition (4C algorithms and programs) - Abdullah Khanani
def multiply(x, y):
    count = 0
    result = 0
    while count < abs(y):
        result += x
        count += 1
    return result if y > 0 else result * -1

# Test cases
print(multiply(2, 5))
print(multiply(2, -5))
print(multiply(-2, 5))
print(multiply(-2, -5))

65.

# Incorrect Answer D
# as a popcorn hack (binary challenge), create string and concatenation options for A, B, C
 
animal = "jackrabbit"[0:4]  # Substring("jackrabbit", 1, 4)
animal += "a"  # Concat(animal, "a")
animal = "antelope"[4:8] + animal  # Concat(Substring("antelope", 5, 4), animal)
print(animal)  # Outputs: lopejacka

animal = animal - "a"
animal = animal + "animal"[3:5]
print(animal) # Should output: lopejackmal

Previous MCQs

2018 Practice MCQ Revisions 2020 Practice MCQ Revisions

Scores

Part 1: 0.8/1

Part 2: 0.93/1

Part 3: 0.9/1