Courses‎ > ‎APCS - Term 1‎ > ‎Konstantinovich‎ > ‎

2019-04-03 APReview HW

posted Apr 3, 2019, 6:26 AM by Konstantinovich Samuel   [ updated Apr 3, 2019, 10:30 AM ]
Exam: Next Friday. All prior topics for the whole year.
Excluded: Radix sort.

Regarding College Recs.
    1. Recognize that I am looking at your performance in my class but need more than just numbers. If you are a silent student that scores well and nothing else, it is difficult to write a rec. 
    2. You should be looking to major in CS or closely related field. This is only flexible if you had me for more than 1 year of classes. 
    3. You should be comfortable communicating with me - because I will be interviewing a large subset of the people I will write recs for. 
    4. Recognize that you will be spending more time writing a much more in-depth response later. (Due by August if you want to apply early.)
If this is acceptable you will need to come speak to me about why you want me to write your rec outside of class. (301 periods 6,7,8, or after 10th)

For in class review/homework we will all use the 7th edition APCS baron's book. 
You can print it out in sections for ease of completion of practice exams.

Is your Google-Fu good enough? If not:
ap computer science baron's book pdf

Multi Day Homework due Monday: 
Practice Exam 2 - multiple choice quesitons. 1-40
On paper with an appropriate heading: (you can STAPLE multiple pages together)
 1-Write the choice,
 2-show any tracing work / write a justification in your own words.
If you do not follow directives 1+2, 0 credit will be given for the entire homework.

AFTER - go over the answers your self. We will only discuss problems you didn't understsand.
(Monday we can discuss any you didn't understand)
Put a STAR next to questions you need to discuss in class. Write a note about why you were confused.

GOAL: Iterators!

Iterable<T> - an interface for Traversable data structures that contain T's. It returns an iterator to be used in the traversal.

iterator<T> - An object that has 'next()' a method that can get each of the elements one after another. It is effectively a black box that keeps track of the current element, and returns it to you untill none are left.

Any iterable data type can be used in the enhanced for loop.

ArrayList<String>data = new ArrayList<>();
//add some values
for (String s : data){

This is equivalant to:
ArrayList<String>data = new ArrayList<>();
//add some values
Iterator<String> iter = data.iterator();
while(iter.hasNext() )
    String s =;
You can re-use the value if you put it into a variable like s.
Without using a variable you cannot reuse next() as it gives you different values each time.

If you don't want a temporary variable:
for(Iterator<String> iter = data.iterator(); iter.hasNext() ; ){
    String s =;