CDAT - Computer Science‎ > ‎AP CS A‎ > ‎AP CS A News‎ > ‎

1FEB

posted Jan 30, 2017, 9:01 AM by Tom Culpepper   [ updated Feb 1, 2017, 5:02 AM ]
Here's the first of many code tracing problems.  I'll go over this about 10 minutes into class.  You should have  it done by then.  I'm not planning on taking these for a grade, unless I need to.

public static int bar(String str){
    if (str.equals("")) 
        return 0;
    else 
        return 1 + bar(str.substring(1));
  }

What will be returned from a call to bar("squishy")?

Write. It. Down.

Written exams are now graded.  You'll get them back today.  As usual, correct it and show me what you fixed for 40% points back.

Some of you are having trouble with the ragged matrix problem.  Here are the steps you need to take.  Each of them is a pretty easy step.  easy + easy + easy != hard

1)  Figure out what the longest row (most columns) is in the original ragged array.
2)  Create a new array with an identical number of rows and a number of columns equal to the columns found in the longest row of the ragged array.
3)  Copy the contents of the original array into the new one.

UPDATE:  I attached two .java files to help you fix the free response questions.
ċ
Book.java
(0k)
Tom Culpepper,
Feb 1, 2017, 5:01 AM
ċ
FreedonianArchives.java
(1k)
Tom Culpepper,
Feb 1, 2017, 5:01 AM
Comments