u/AeroNasa

CSP Explanation
▲ 1 r/apcsp

CSP Explanation

Source: Barrons

Saw many people in someone's previous post arguing that its D. However, I believe that the answer is C and am confused why everyone says it's D.

Here's why I believe it's C and not D:

Let List be equal to [1, 3]

Let's hand trace this

ALGORITHM #1:

sum = 0

count = 1

sum = 0 + 1 = 1

count = 1 + 1 = 2

Count is equal to 2 (the length of list)-->Don't iterate again (loop is done)

ave = 1/2 = 0.5

Return 0.5

Incorrect average, Algorithm A has failed.

ALGORITHM #2:

sum = 0

count = 1

sum = 0 + 1 = 1

count = 1 + 1 = 2

ave = 1/2 = 0.5

Count is equal to 2 (the length of list)-->Don't iterate again (loop is done)

Return 0.5

Incorrect average, Algorithm B has failed.

CONCLUSION:

Essentially, both algorithms will, in all cases, prevent us from considering the value of the last item in our list because when count increases to list.length (the index of the last item in our list), the REPEAT UNTIL loop ends before we can add the last item to our sum, ultimately leading to an incorrect average.

I believe this question is extremely poorly written by Barron's. Barron's claims the answer is D which, as I've shown above, I think is inaccurate.

Please don't hesitate to correct me if I'm wrong!

reddit.com
u/AeroNasa — 22 hours ago
▲ 2 r/apcsp

Less than 24 Hours Left

It's now or never guys.

Just a reminder to not cram the day before the exam-- it's far better to keep your mind fresh and just have a relaxed study session practicing MCQs and FRQs. Good luck!

reddit.com
u/AeroNasa — 1 day ago
▲ 3 r/apcsp

How to tackle the 2024 FRQ 2C question

QUESTION: (c) Suppose another programmer provides you with a procedure called checkValidity(value) that returns true if a value passed as an argument is considered valid by the other programmer and returns false otherwise. Using the list identified in the List section of your Personalized Project Reference, explain in detailed steps an algorithm that uses checkValidity to check whether all elements in your list are considered valid by the other programmer. Your explanation must be detailed enough for someone else to write the program code for the algorithm that uses checkValidity.

Only about 20% of students got this right.

Whether you're lucky and get an easy FRQ for 2C or you're unlucky and get one similar to this, it's critical you are at least aware with how to solve these types of problems.

2C is basically the FRQ that really shows if you used AI to write your code for you, because you need a general coding background for this.

Well, let's get rolling, shall we?

SOLUTION/EXPLANATION: Let's break this down.

  • We're given an external procedure, called checkValidity(value). It's going to take some sort of value, and if the other programmer thinks its valid, it'll return true. If the other programmer thinks its invalid, it'll return false.
  • We're going to tackle this by using checking to see if all items in our list are valid. If they are all valid, we can conclude that our list is valid. If just one item/element is invalid, then we can conclude that our list is invalid as a whole.
  • We are being asked to "explain in detailed steps an algroithm." So, we can literally write the code + a minimal explanation, or we can just describe it (in much, much detail, to the point someone else can rewrite the code).

for (var i = 0; i < myList.length; i++) {

List has been initialized/declared, with a set boundary, i declared, and i increasing by 1 at the end of each loop.

if (checkvalidity(myList[i])) {

For loop traverses through myList using index i.

count++;

Increases count by 1 if the item is valid. Assume count has been correctly initialized above.

}

}

if (count == myList.length) {

console.log ("Your list is valid!");

} else {

console.log("Your list is invalid!");

}

Checks to see if all items in myList are valid. If they are, our list is valid! Otherwise, if just one is invalid, count won't be equal to myList.length, making our list invalid.

Good luck on AP CSP this Thursday!

reddit.com
u/AeroNasa — 4 days ago