Computer Science A(B)

<p>Alright... think I'm sort of ready. Still four questions (AB):</p>

<p>1) With superclass methods if they are not overidden, they are automatically called if something calls them from outside or within the subclass and same goes for instance fields.</p>

<p>If a subclass is cast as a superclass calling an overriden method calls the subclass method.</p>

<p>Does super.(whatever) only have to be used to access things that are overriden?</p>

<p>That's right right?</p>

<p>2) We do not need to know the implementation or red black trees, correct? only that of generic binary search trees?</p>

<p>3) Gridworld code is available while writing, right? (that much familiarity needed?)</p>

<p>4) anyone know the curve for either exam?</p>

<p>Anyone else who has last minute study problems/questions can add them. And/Or try and answer mine.</p>

<p>You're right about the first part (what you're describing is called polymorphism, by the way). You don't need to know red-black trees, but you do need to know extensions of binary trees as well as related structures (for example, postfix and prefix arithmetic, a max-heap, etc.). You won't get the actual code for GridWorld, but you will have a list of all the methods that are at your disposal, I believe. According to my Barron's review book, 70-100 points corresponds to a 5 and 60-69 corresponds to a 4.</p>

<p>70-100 out of 100? That's less than a generous curve but still pretty good I guess. No chance of a three which was my plan. </p>

<p>I know postfix and prefix arithmetic but not how they relate to trees.</p>

<p>Like 4 5 6 7 + - /
is equal to 4 / (6 + 7 - 5)</p>

<p>And a max-heap is just a min-heap upside down right? E.g. you put things in the next available slot and if they're too big bubble them up perhaps all the way to root.</p>

<p>Postfix and prefix arithmetic relates to trees since traversing a tree containing a valid expression using postorder will produce that equation in postfix form, for example. You're right about the max-heap (also, you should know what constitutes a complete binary tree and a perfect binary tree). In terms of grade distribution, the CS AB exam is one of the easiest APs available, so you should be fine.</p>

<p>I thought the entire exam was out of 80 points. 40 points on MC and 36pts * 1.1111 on FRQ. I have the 2008 Computer Science A/AB book, and I was not able to find a composite -> ap grade table. Anyone know for sure? I just called a CollegeBoard lady, and apparently they only give that number out to AP Coordinators.</p>

<p>The 2006-07 PR book I have says that 60-80 pts results in a 5. (which would be a 56-80 if you scaled the 70-100).</p>

<p>EDIT
Okay, I just found the chart in my barron's book. I don't know why they did the chart like this, but they multiplied the MC raw score by 1.25 and the FRQ by 1.39. Which is kind of the same thing as just multiplying the FRQ by 1.1111 (1.39/1.25 = 1.12).</p>

<p>How do you guys track a recursion through a tree? Also I think in 2004 the curve was a 68-100 for a 5.</p>

<p>"Postfix and prefix arithmetic relates to trees since traversing a tree containing a valid expression using postorder will produce that equation in postfix form, for example."</p>

<p>?? Sorry, I don't follow. How does a tree store an arithmetical expression...</p>

<p>oh, as all inner nodes as operations and all leaves as numbers to which the rooted operation occurs?



                 +
              /     \
            *        -
          /   \     /   \
        3    4    5    6


Which if you traverse in post order gives you:
3 4 * 5 6 - +</p>

<p>I suppose preorder traversal gives prefix notation. Neat. </p>

<p>Wiki says that complete and perfect trees are both just trees with all leaves at the same level. Is that what you meant?</p>

<p>Snipez90:
recursively maybe? Depends what you're trying to do, you usually just keep going until you no longer have any child nodes to pass to the method you've been calling repeatedly.</p>

<p>If I understand what you're saying.</p>

<p>Well, kind of. For a tree to be complete, all of the leaves have to be as far left as possible -- that is, you can't have a "gap" of any size between two leaves. A perfect tree contains a filled lower layer of leaves with nothing missing. Also, the CS A curve is indeed out of 80, but for CS AB, it's out of 100.</p>

<p>Sorry I meant in general do you guys test small cases a lot? I think I'm just really lazy. Usually I'm not lazy enough to just take a leap of faith and assume my one test case leads to a generalization but sometimes I just find it a pain.</p>

<p>sometimes I do sometimes I don't (depends if I feel lazy). You always want to make a test case that tries all the border situation so you know it can be generalized though. </p>

<p>For sorting/searching we only need to know linear search, binary search / bubble sort, selection sort, right?</p>

<p>We don't need to be able to right a qsort or heapsort of anything.</p>

<p>No bubble sort needed, to my knowledge. We need insertion, selection (and if your taking AB: merge and quick and heap) sorts.</p>

<p>Could anyone discuss polymorphism and what causes ClassCastExceptions?</p>

<p>uaarrggh. How well do we need to understand merge/heap/quick sorts... do we need to be able to write them?</p>

<p>ClassCastException is when you try to cast something to an object it is not an instance of e.g.



Object x = new Integer(0);
System.out.println((String)x);


</p>

<p>They won't ask you to regurgitate any sort/search code, but you should be able to recognize it, I think. You most definitely need to know the big-oh run time for the sorts though, as well as for the data structures. Yeah. I second your Uargghh.</p>

<p>How does the ClassCastException work when you're doing inheritance stuff. I am trying to do an example in eclipse, but I don't think I'm understanding it.</p>

<p>If there is a Class called ClassOne and it has a subclass ClassTwo (ClassTwo extends ClassOne) </p>

<p>okay so you have</p>

<p>ClassOne c1 = new ClassOne();
ClassOne typeC1defC2 = new ClassTwo();
ClassTwo c2 = newClassTwo()</p>

<p>and you do typeC1defC2.methodOnlyInClassTwo(); then there is no problem, right?</p>

<p>but what if you have a method in ClassOne that is overridden in ClassTwo and you do</p>

<p>((ClassOne) ClassTwo).methodInBoth(); whose method runs? The ClassOne method (because ClassTwo is being casted into ClassOne) or the ClassTwo method?</p>

<p>Thanks for the help.</p>

<p>Eclipse? pfft. Textpad ftw. </p>

<p>Anyways my understanding for: typeC1defC2.methodOnlyInClassTwo(); there could be a problem (dunno). I'd usually </p>

<p>((ClassTwo)typeC1defC2)methodOnlyInClassTwo();</p>

<p>just as policy. </p>

<p>For you second question, the shared method is pulled from the subclass. The subclass method (from ClassTwo) overrides that from the super even if the object is casted as ClassOne.</p>

<p>You have ClassCastException if you say have a ClassThree that is also a subclass of ClassOne and you</p>

<p>ClassOne Cl1 = new ClassTwo()
ClassThree Cl3 = (ClassThree)Cl1</p>

<p>Essentially, polymorphism is having two methods with the same signature but alternate implementations. For example, you can have a class Animal whose act() method goes one step forward; a subclass of Animal, Bird, can override that act() method and define it to make the bird flap its wings once. Also, the Bird class can have a fly() method which the Animal class does not have.</p>

<p>Animal a1 = new Animal();
Animal a2 = new Bird();
Bird b1 = new Bird();</p>

<p>a1.act(); // The animal moves one step forward.
a2.act(); // The bird flaps its wings once; this is an example of dynamic binding, as the act() method of the subclass is used despite the initial declaration of a2 as type Animal.
b1.act(); // The bird flaps its wings once.</p>

<p>a1.fly(); // Illegal -- fly() is not defined for an Animal.
a2.fly(); // Illegal (throws a compile-time error, same as before).
b1.fly(); // Valid.</p>

<p>Of these, what happens when you call the methods of a2 can be somewhat tricky.</p>

<p>Textpad? I do it the old-school way in pure Notepad, yo.
Anyways. I'm kind of iffy for tomorrow's test - still don't have GridWorld down very well... I put off looking at it until three days ago.</p>

<p>Notepad doesn't have syntax highlighting. That's wack.</p>

<p>Need to review gridworld myself... hardly know it at all but I'm pretty sure I can figure it out on the test. Most case study questions you only need to make 1 or 2 outside method calls and its usually to an obvious class.</p>

<p>So GL all. Hopin' for some 5.</p>

<p>Best of luck to everyone taking it today (tomorrow) :)</p>

<p>Good luck guys. I'm heading out for my exam now ;)</p>

<p>Just finished :), wasn't that bad. Made some random **** up for a few essays, but what can 'ya do :P</p>