2011 Computer Science Test Thoughts

<p>Here was my entire class. I wrote processActors using an ArrayList of Actors. :(</p>

<p>



public class AttractiveCritter extends Critter {</p>

<p>public ArrayList<actor> getActors() {
return getGrid().getOccupiedLocations();
}</actor></p>

<p>public void processActors(ArrayList<actor> actors) {
Actor tempActor;
Location tempLocation;
int dir=0;
for(int x=0;x<actors.size();x++) {
tempActor=actors.get(x);
int dir=getLocation().getDirectionTowards(tempActor.getLocation());
tempLocation=tempActor.getAdjacentLocation(dir+Location.HALF_CIRCLE);
if(getGrid().get(tempLocation).equals(null)) tempActor.makeMove(tempLocation);
}
}</actor></p>

<p>}


</p>

<p>^ I did that too ):
I only overrode the processActors method and I had had to guess on the last 3 MC questions.</p>

<p>Considering the fact that I didn’t do anything in class all year and crammed most of my studying, I’ll probably get a 3 or a 4. ><</p>

<p>sorry for the repetitive post, but appass.com claims that ap comp sci will have a 78% curve for a 5, while most other ap’s are like 63%. Is this true, and if so why? Thanks.</p>

<p>Different exams are scored with different kinds of rubrics. That leads to different kinds of raw scores on the FRQs and the MCs. That’s ok. All that matters is, at the end of the day, the final score (1-5) fairly reflects what you know.</p>

<p>@AndrewT: Being a fan of simplistic code, I posted some (less jumbled) alternative ways to do three (really only two) of the programs:</p>

<p>1b) Note: To show it is also possible to use a while loop. Note I also flipped beginning point of i, which will work if you also flip the index being called in the loop (as I have).



public void trimSilenceFromBeginning() {
    int firstSound = 0;
    while(firstsound<samples.length && samples[firstsound] == 0)
    {firstsound++;}
    int[] newSamples = new int[samples.length - firstSound];
    for (int i = firstsound; i < Samples.length; i++) {
        newSamples[i - firstsound] = samples*;
    }
    samples = newSamples;
}

3b) Math.abs works because collegebaord allows you to use code from whatever common library you want.



public void moveToLocation(int locIndex) {
    if ((locIndex > filler.getCurrentIndex() && !filler.isFacingRight()) 
    || (locIndex < filler.getCurrentIndex() && filler.isFacingRight()))
        {filler.changeDirection();}
    filler.moveForward(Math.abs(filler.getCurrentIndex() - locIndex);
}


4a) Andrew, I think you may have a flaw in your program. I can't quite tell what you want to do with index, but it will not work. I simply changed index, other than that, this is the same exact code.



private void fillBlock(String str) {
    int index = 0;
    for (int row = 0; row < numRows; row++) {
        for (int col = 0; col < numCols; col++) {
            index++;
            if (index >= str.length())
                letterBlock[row][col] = "A";
            else
                letterBlock[row][col] = str.substring(index, index + 1);
        }
    }
}


</p>

<p>Some other small things:
In 1a, I think that you meant to have an else if{} statement. The way you have it works, but it is rather awkward.
In 2, you do not need to test is a != null in getActors. getOccupiedLocations will check for that.</p>

<p>Also, I hope that none of these comments offend you. I am simply posting these as other solutions. Also, you deserve the credit for typing these =).</p>

<p>@ apcalc</p>

<p>Your program for Gridworld 2a won’t exactly work because you’re supposed to return an arraylist of actors and getOccupiedLocations returns an arraylist of locations…</p>

<p>I know. :(</p>

<p>That is what I am asking - how many points do you guys think I will lose for that? I think I did the other FRQs perfectly, so if I don’t take too big of a hit here, I still might be in good standing for a 5! :)</p>

<p>im going to say .5-1 point will be taken off. If you look at past rubrics, the most any one mistake will give is like minus 2 points. You still had a return statement, so thats around one point in itself.</p>

<p>I agree with Lawliet99. I have no idea what the rubric will look like, but you’ll certainly get some partial credit. You picked the proper method to override; you realized that you needed to look at all occupied locations, not just the neighbors; you attempted a return. Of course, your return type was incorrect, and you didn’t return the correct values.</p>

<p>It all depends on how many points are assigned to that problem but … you’ll get some credit.</p>

<p>

</p>

<p>Actually I think it will work fine.</p>

<p>


int index = row * numCols + col;

</p>

<p>In a 4 x 4 grid, if row is 2 and col is 1 (third row, second column), index will be 9, as it should be. If row is 1 and col is 3 (second row, fourth column), index will be 7, and so on. It might seem a bit strange, but it’s actually a pretty common way to calculate a one-dimensional index from a two-dimensional position in an array.</p>

<p>Trying to understand… Are these the one-dimensional indexes in a 4x4 array? (column major)


0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15

</p>

<p>Yes, although if it’s column major you would have to calculate the index using index = col * numRows + row.</p>

<p>Looking at past AP CS Exams this one seemed to be significantly harder, at least the multiple choice was. Personally, I finished early on both parts, but everyone else seemed to have much more problems. Does anyone else think this is due to the fact that they removed guessing penalties and used that as an excuse to make the multiple choice harder?</p>

<p>@AndrewT</p>

<p>I am sorry, you are right. That was the first time I ever saw a double array traversed like that. I am also not use to declaring the iterator in the loop. But, regardless, I spoke too fast and it works.</p>

<p>Also: completely random off-topic question:
Does anyone know how to set the location of a random number of JTextfields so that they are evenly spaced? I have a user-picked number (aka, x) sent into a method, a for-loop making an array of the JTextfields with x elements, and now I just need to set the location (which I need help with). If you know please PM me.</p>

<p>This is what I did for the trim silence (a rather unorthodox way)…I made samples an Array List instead of just an array.</p>

<p>Code:</p>

<p>public void trimSilenceFromBeginning() {
for (int i = 0; i < samples.size(); samples.get(i)==0; i++) {
samples.remove(i); {</p>

<pre><code> if (samples.get(i) != 0)
break;
</code></pre>

<p>}</p>

<p>Newton391244:
A few errors…</p>

<p>You never made an ArrayList. That’s still an array. Thus:</p>

<p>.size is incorrect - should be .length (.size should be .size() for an arraylist anyway)
samples* = 0 should have been ==, it’s unnecessary anyway though
.remove does not exist…</p>

<p>If you made it an arraylist you would have had to make that list, put all values of samples in it, removed the 0’s in the arraylist, then put all values of the arraylist back into samples.</p>

<p>@Andrew T</p>

<p>I did something like this</p>

<p>public class AttractiveCritter extends Critter {
AttractiveCritter aC = new AttractiveCritter(); </p>

<p>public ArrayList<actor> getActors() {
ArrayList<actor> actors = new ArrayList<actor>;
ArrayList<location> locs = getGrid().getOccupiedLocations();
for (Location loc : locs) {
Actor a = getGrid().get(loc);
if (a.size() != null) {
actors.add(a);
}
}
}
public void processActors(ArrayList<actor> actors) {
for (Actor a : actors) {
Location loc = aC.getLocation();
Location myLoc = a.getLocation();
if (a.canMove())
a.setDirection(getDirectionToward(loc));
a.move();
else
super.makeMove();
a.moveTo(newLoc)
}
}
}
}
Would they take off that many points for that?</actor></location></actor></actor></actor></p>

<p>@ kkchen</p>

<p>Actually… pretty much everyone in our class said the Multiple Choice was easier than practice tests we’ve taken and there were very few questions on the hard stuff like recursion. </p>

<p>But, after all, everyone has their own opinion :p</p>

<p>Although you are right, I expected them to make it harder due to guessing penalties being removed. Either that, or less curve. </p>

<p>@Newton391244</p>

<p>In your processActors method, there is no move() or canMove() method for critters first of all(bugs)</p>

<p>I would say -2 for the entire problem</p>

<p>Sorry for double posting</p>

<p>But I was curious, for the problem 1b with the trimming silence… I did everything right, except when I was assigning the new array all the values of the old array like</p>

<p>newSamples* = samples[j]</p>

<p>I made 2 for loops with 1 variable each (i and j) instead of one for loop with 2 variables incremented… how much would I lose for that? 2 points?</p>

<p>I didn’t take the AP exam, but in looking for websites to start my self-study of the course I found this: [AP</a> Computer Science Exam Review and Free Response Practice Problems](<a href=“http://apcomputersciencetutoring.com/exam-review/]AP”>AP Computer Science Exam Review and Free Response Practice Problems)
He provides his explanations for all of the short answer questions. Maybe this will help some of you.</p>