My Score

Screenshot 2024-01-03 at 2 59 14 PM


I did a little better on this one that the other one percentage wise, although I feel like I would have done better If I had not done it in a car on a roadtrip. Overall, I feel decent knowing that I did pretty well and definetely could do better since my errors were silly mistakes.

According to the time on CB, the test took me more than 2 hours but this is pretty unaccurate or not a true measurement of my timings since I did the test on a road trip and was using my hotspot and we were on mountains and the hotspot would turn on and off at certain times and sometimes the college board would freeze and kick me out and I would just finish the question on the paper and then put the answer in quickly when data came back and sometimes I would move to the next question and and then get kicked out right away or something. This happened constantly, and it became extremely hard and annoying to put in the answers, and so I learned my lesson of not doing assignments to the last momment.

Soemthing that I feel good about is not using outside resources, anyways I couldn’t even use outside resources like google because of how bad my wifi was. I also feel good about how I was able to find different ways of doing a single problem and quick ways of doing problems, like the sorting ones, where I did not even have to look at the code as I knew the process of the sorting. Another one was the question where I used a log equation to solve it(question 36) where you could have just put in the elements and divided by two and kept doign that untill you get the answer but I found a quicker way of doing it through logs.

Work I did when taking the CB

Note: A Lot of my timings are extremely messed up like 14 minutes or even 5 seconds, since I did this on a road trip and the hotspot was extremely bad since we were on the mountains and the data gets cut off sometimes and then it would just kick me out of college board and also some of the times it would just not do anything on the screen for a while and not move to next question and freeze out and so I wrote down all my problems and steps just in case if something did not enter in due to internet. Also writing down steps really helped me process each and every step of the question to avoid silly mistakes and better thinking. I know you don’t like paper but on the CB exam it really helps me think and not jumble too many things in my head which leads to errors and confusion. Also jsut for extra here are the picture of all my steps I did for every problem and it can kind of show how I thought through and did each question.

IMG_5273 IMG_5276 IMG_5270 IMG_5271 IMG_5267 IMG_5268 IMG_5275

Specific Quesitons Reflections

Q4 findMax of 1D int array

Screenshot 2024-01-03 at 3 07 51 PM

I really liked this question, as I recalled doing it, I did this pretty fast i think under a minute easily as I looked at the question and saw that the if statement in the for loop does not update if the value is negative since maxVal is set to 0. This came to me extremely fast and it was a question that I really enjoyed, questions like these on the test will be really good for me since it will give me time to think more on other questions if I ever get stuck, in order to get the question right.

Q7 outer and inner loops with multiples of 2

Screenshot 2024-01-03 at 3 16 43 PM

When I first saw this question, it didn’t look to difficult but too easy at the same time as it was a basic nested for loop. I thought to myself it would be hard doing in my head so I wrote it down and approached this question step by step. I first started with the first iteration of the outer loop which resulted in 2 4 6 as those were the ones that had a remainder of 0 when divided by 2. Then for the second iteration of the outer loop, this resulted in 2 4 6 also since the inner loop is stil at 2. Then the third iteration resulted in 4 6 since the inner loop is on its 3rd iteration and so the numbers that are divisible by 2 without remainder are 4 and 6. Then same thing with outer iteration of 4. Then for outer iteration of 5, only numbers left that were divisible by 2 was 6 and this was same thing for outer iteration of 6.

Q9

Screenshot 2024-01-03 at 3 29 25 PM

This one was a little tricky as I had to read it carefully and think it through, I knew that math random generated a number 0 through 1 so you had to multiply by 6 in order to give us the range of 0-5. Then I knew we had to roll two number cubes and take the sum of them and int is needed which truncates the decimal. This right there eliminated A,B,D and only options left were C and E. Right now the range is 0-5 and a cubes range is not 0-5, it is 0-6 so to each cube you need to add 1, and since we are rolling two cubes you add 2 so the option was E. I really liked this since it was the fundamentals of math.random and it was kind of a breeze through elimination and once it came down to two options it was pretty easy.

Q12 Compound Boolean expression with variable x and y

Screenshot 2024-01-03 at 3 36 09 PM

This question really fascinated me when I looked at the explanation, as I forgot about De Morgan’s Law in the sense of applying it. The way I approached it was basic logic of just plugging in false and true for each of the boolean variables with different combinations and then coming to the conclusion with the results that this was always false no matter what I put. Then once I looked at this explanation on CB, I saw we can use De Morgan’s Law which I totally forgot about.

De Morgan’s Law tells us that !(x || y) is the same as !x && !y. If x and y are both true, !x && !y has to be false, because both are flipped to their opposite. So, when you put it together like (x && y) && (!x && !y), it’s clear it’s always going to be false. It’s like saying “it’s both day and night at the same time,” which can’t happen. With DeMorgan’s Law I would have saved a lot of time on this problem and have been able to use more time on future harder problems.

Q13

Screenshot 2024-01-03 at 6 02 54 PM

This problem I liked beacuse it required me to think a little bit. I approached the problem like this: the k = k + 3, with k = 1, in the for loop, I came to see that the mystery call 3 starts with index 1 and increments 3 indexes until the length of the array which is 10 values, so 1,4,7. Then inside the for loop, it takes the number before every third index and adds it by three and then replaces that number with the index. So in this case, 34 gets replaced with the previous index (17) and 3 added to 17 which is 20. Then the third index value which is 15 gets replaced with the previous index (42) and adds 3 to get 45 and so on so forth untill the length of the array. This was really confusing me at the beggining but, once I broke it down step by step it and wrote it down it helped me with the problem to solve it.

Q15 showMe Method with int Parameter

Screenshot 2024-01-03 at 6 44 22 PM

This question I am shocked I think I did a silly mistake or was not paying attention properly since I was doing this in the car but doing this right now, the right answer would be A since arg = 0 right now and since arg is less than 10 it would be called and added 1, this method would recursvely call this if function and add 1 to arg every time until arg is equal to 10 and this would print out 10.

Q16 Calculate Method with 2D int array parameter (DO THIS ONE)

Screenshot 2024-01-03 at 7 28 53 PM

This question to be honest I just guessed the answer because I was a little confused on this, and luckily I guessed correctly. But once doing research and seeing the college board explanation I understand it and it is pretty simple. Here is my explanation of my understanding:

step by step:

  1. You start at the top-left corner of the grid (row 0, column 0), and this is your current best find.
  2. You look through each row, one by one, checking every spot in that row.
  3. If you find a number bigger than your current best find, you update your best find to this new number, and you note down the column number (because that’s where you found your new best treasure).
  4. After you’ve searched the whole grid, you won’t have the biggest number itself, but you’ll know which column it was in.

So, the method doesn’t give you the biggest number, but it tells you the column where you can find it.

For a little extra work of my understanding I wrote out the code and put comments on each part of the code and what it does.

public static int calculate(int[][] values) {
    int found = values[0][0]; // Start at the top-left corner, this is the first number we see.
    int result = 0; // This will keep track of where the largest number is found, starting with column 0.

    // We begin our search, row by row.
    for (int[] row : values) {
        // In each row, we check each cell, one by one.
        for (int y = 0; y < row.length; y++) {
            // If we find a number bigger than any we've seen so far...
            if (row[y] > found) {
                found = row[y]; // This is our new biggest number.
                result = y; // And it was found in this column.
            }
        }
    }
    // Our search is over. We return the column index where the biggest number was found.
    return result; 
}



## Q17 doWhat method with positive int parameter

![Screenshot 2024-01-03 at 7 34 24PM](https://github.com/nikhilc3/csa/assets/111464993/86816e48-2758-45a5-8e5f-7660bb5a394d)

Although this one was fairly easy and I remmeber doing this fairly quick and way under a minute, Just wanted to reflect on this one as a question that was super easy but could have saved time by not writing down the steps. Basically the variable is initialized to 0 and the for loop starts at 1 and adds 1 to 0 then the loop increments by 2 and adds that to var so basically it is the sum of all odd integers between 1 and num inclusive although I wrote down all the steps of it adding and I did the problem with an exaple number of num as 5 which was not necesary as I could have easily just looked at the logic and saw the answer. 

## Favorite/Highlight question of the CB quiz
Q23 Insertion sort on 1d int array
![Screenshot 2024-01-03 at 7 39 44PM](https://github.com/nikhilc3/csa/assets/111464993/d255262e-6399-47eb-9f9f-9aa65fc335d0)


For this one I did not even have to look at the code process at all and put in the numbers through that, I knew how the insertion sort worked and from there it was extremely easy, like it took a few seconds. As soon as I saw insertion sort, I looked at the initialized values and preformed insertion sort 2 times. Basically how insertion sort is we put the 1st value as sorted which was 5, and looked at the next element to see if it was less than 5 and it was so place it before it. Now we know the 4 sorted so we look at 3 and compare it to 4 and 5 and we see that it is less than both 4 and 5 so we place it before 4 and so the values right now on the second step are 3,4,5,2,1 which is answer C. Recognizing this question or these type of questions where you do not even need to look at code and can complete question is extremely vital during the test as it can save you a lot of time. This insertion sort is also similar to what we preformed in the sorting algorithm for our miniproject as shown by my code in the mini project:
<br>

```java
package com.nighthawk.spring_portfolio.mvc.sort;

public class InsertionSort {

    public static void sort(int[] array) {
        long startTime = System.nanoTime();

        int n = array.length;
        for (int i = 1; i < n; ++i) {
            int key = array[i];
            int j = i - 1;

            while (j >= 0 && array[j] > key) {
                array[j + 1] = array[j];
                j = j - 1;
            }
            array[j + 1] = key;
        }

        long endTime = System.nanoTime();
        long duration = (endTime - startTime);
        System.out.println("Insertion Sort Time: " + duration + " nanoseconds");
    }
}

As you can see here the code that I coded in the mini project is extremely similar to the one in the college board question.

Q25 Incrementing count in nested loops

Screenshot 2024-01-04 at 2 50 39 PM

I decided to put this question because it really stressed the importance of writing the steps down on a piece of paper during the test, and doing in head can lead to small error which can lead to problem being wrong. First I looked at the first iteration of the outer loop and marked as 0, then i saw for this iteration, the inner loop iterates 4 times through count, 1,2,3,4, so the count is 4 as it increases once every time. Then the second iteration of the outer for loop, the x value is 1 right now and so the inner for loop iterates 3 times, 1,2,3 and adds one every time so 4+3 = 7. Second iteration of outer for loop, the count is 7. Now the third iteration of the for loop when the x value is 2, the inner for loop iterates 2 times with the y values of 2,3 and this produces an overall count of 9. Now on the fourth and final iteration of the outer for loop with x = 3, the inner for loop iterates once with y value of 3 and the count increases one last time to 9+1 = 10. So the correct answer is 10, C.

Q27 Sorting 1d int array (second favorite question)

Screenshot 2024-01-04 at 3 01 46 PM

These types of questions, the sorting ones, are easily one of my favorites as I have coded them in the mini project so they are easily identifyable and I can do them extremely fast as I know the process of each sort. As soon as I read the problem I quickly looked at the code and identified the format very fast as this format was a selection sort and extremely similar to the one I coded in the mini project, just different variable names. Then I wrote down on my piece of paper and worked out the three passes of the selection sort. First you swap the smallest element (1) with the first element(6) in this case. Then second step find the samllest element in the unsorted list, numbers after 1, and the smallest element was 2 and then we swap the second element in the list with the smallest element from the unsorted list. Now you are at: 1,2,3,5,4,6. Then for the third step you do this again for the unsorted list (3,5,4,6), you find the smallest element in the unsorted list in this case which is 3 and swap with the third elemnt which is 3, so the list stays the same in this case. So after three passes, the values are 1,2,3,5,4,6 and this is option B. Doing the backend sorting calculations for the miniproject really helped me recognize the sorting extremely fast. The insertion sort in the problem is very very similar to the one I did in the mini project:

package com.nighthawk.spring_portfolio.mvc.sort;

public class SelectionSort {

    public static void sort(int[] array) {
        long startTime = System.nanoTime();

        int n = array.length;

        for (int i = 0; i < n - 1; i++) {
            int min_idx = i;
            for (int j = i + 1; j < n; j++)
                if (array[j] < array[min_idx])
                    min_idx = j;

            int temp = array[min_idx];
            array[min_idx] = array[i];
            array[i] = temp;
        }

        long endTime = System.nanoTime();
        long duration = (endTime - startTime);
        System.out.println("Selection Sort Time: " + duration + " nanoseconds");
    }
}

Q31 X and O board

Screenshot 2024-01-04 at 3 39 43 PM

I chose this because at first it looked kind of hard but once you wrote the steps down and did the for loop replacing each 0 with x, it was pretty easy. Basically the first for loop makes every thing on the table O. then basically we go to the second for loop and lets look at the first iteration, the value of 0 does not pass the if statement so we go to second iteration, of val = 1, this does pass the if statement so we set row to 1 and col to 0 and then put and then go to the while loop which then sees if col<5 and row >=0 then put an x and add 1 to col and -1 from row, so now col qand row = 0 and col = 1, so there is an x at r=1, c=0 and r=0,c=1. Then for the third iteration of value 2, it does not pass if statement so we go to next iteration of 3. In this row = 3,col=0, for the if statement, and x is placed, then going to the while loop, r=2,col=1 and r =1 and col=2 and r=0,col=3 and then for next iteration of outer for it is 4 which does not pass if statmenet so then loop terminates. So the values placed on the board are on r=1,col=0 amd r=0,col=1 and r=3,col=0 and r=2,col=1 and r =1,col=2 and r=0,col=3. Putting these steps on paper makes this problem extremely simple as it may seem very hard to do when doing in your head.

Q33

Screenshot 2024-01-04 at 4 09 19 PM

I do not think I was looking at the problem properly, it is obviously all three and not just 2 and 3. Basically 1 is correct since max is initially set to minimum value and basically as it iterates through the array, if there is a value that is greater than max, it replaces the max with the value and continues to do this untill it can not and this will provide the largest value in the array. I do not know or remember why I got this wrong, I think I was just not paying attention properly as I was doing this in the car but I should have gotten this correct, it was extremely simple. For these loops I did not need to write anything down but it usually is important to put down steps on pieces of paper as small errors or simple mistakes can occur, but in this problem it was not necessary.

Q36 Iterative binarySearch statement execution count

Screenshot 2024-01-04 at 4 33 48 PM

This question on the CB test was probably my third favorite question as for the different methods we could do it. The way I did it at first was I saw that the equation to find out how many times the statement could execute was the total amount of elements(2000) divided by 2^n (2000/(2^n) = 1). This is because for every iteration to find the midpoint you would have to do the start + end/2. Now that we have the equation we can do some Calculas and logarithms, so we multiply both sides by 2^n and get 2^n = 2000. Now we log each side with a base of 2, so we have log base 2 of 2^n = log base 2 of 2000. Now we can cross out the log base 2 of 2 and we just have n = log base 2 of 2000. From here we get n = 11. There is another way to do it without calculus which is the way the College Board explanation did it, of keep dividng 2000 untill you get to 1 and then count how many times you were able to divide it, this way is probably easier to think about than the equation but would be slower. If we had a calculator on the exam, I would use the first method, but if we did not, then the second method is the way to go, as the calculations provide another layer of complexity, although since we are allowed to use a calculator on the APCSA, I went the route of the calculations.

Q39 Consider the following code segment

Screenshot 2024-01-04 at 4 55 04 PM

For this one, I was pretty tired and was not focusing too well and was on a bumpy car and thats why I possibly made this mistake, but basically I thought that it first set every value to alex and then printed it out resulting in every value being Alex but that was wrong. Basically it first prints out Alex,Bob,Carl, while setting each one to alex, so it first prints out those names and then sets it to alex after each one printed, and now that they are set to alex, the next loop runs and it prints out the next three values Alex,Alex,Alex since the names are now set to Alex. So the resulting output would be: Alex,Bob,Carl Alex,Alex,Alex

Overall Reflection

Glows

  • I applied a lot of my knowledege doing and finding different ways of solving a problem and more faster and effecient ways.
  • Doing the backend for the miniproject really helped me as I was able to just look at the sorting, identify it, and solve it extremely fast without even looking at the process of the code
  • I did pretty well in overall score in terms of my working condition and the distractions
  • For questions I was not strong in, I used different context and process of elimination to find the answer. One example of using context and plugging in numbers was the DeMorgan’s Law, which I had totally forgot about it existing and applying it, and I just inputted bolean values. Although If i had remembered DeMorgan’s Law, I would have spent a lot less time on the question

Grows

  • Some Questions I had guessed on because it was just too much to process and I did not really understand some parts of it, luckily I guessed it but maybe learning more of those concepts and practicing more can help me.
  • I should have focused more and not done extremely silly mistakes, like for the questions I got wrong, I did very silly mistakes that were very dumb. This may have been due to my working enviornment or me not thinking properly on those questions, I do not know, but I feel like if I was in a quiet room with testing conditions and true feeling of a test, I definetely would have gotten those right.
  • I think that with more practice I will do a lot better as I will have muscle memory for differenent types of problems in order to do them faster.