Algorithms and OOD (CSC 207 2014S) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions] [GNU Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013F (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Held: Monday, 24 February 2014
Back to Outline 20 - Reasoning About Loops with Loop Invariants. On to Outline 22 - Detour: Anonymous Inner Classes.
Summary
We consider issues from the first examination.
Related Pages
Overview
Administrivia
Here are some of the things I expected:
Long.MAX_VALUE Long.MIN_VALUEAdditional issues:
doubles!It might have been helpful to write a helper that does the conversion in memory, before writing to the file.
What do you see as the difference between
String line = infile.readLine();
while (line != null)
{
...
line = infile.readLine();
} // while
and
String line;
while ((line = infile.readLine()) != null)
{
...
} // while
What do you see as the difference between
ch = line.charAt(i);
if (ch == '\t')
...
else if (ch == '\n')
...
else if (ch == '\\')
...
else if (ch == '\"')
...
else
...
and
switch (ch = line.charAt(i)
{
case '\t':
...;
break;
case '\n':
...;
break;
case '\\':
...;
break;
case '\"';
...;
break;
default:
...;
break;
} // switch
String.replace. I thought the problem was pretty
clear that that approach was not permitted.Some of you used (approximately)
int i = 0;
while (i < contents.size-pattern.length())
{
if (this.matchesAt(i, pattern))
{
this.remove(i, i + pattern.length());
this.prepend(i, replacement);
i += pattern.length();
} // if match at position i
else // if no match at position if
{
i++;
} // if no match at position i
} // while
This solution is potentially quadratic in the size of the input
(e.g., "aaaaaa".replace("a","b"))
Although I said that I was not going to allow a makeup exam, there were enough problems on problems 2 and 4 that I will allow you to make those problems up for partial credit.
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions] [GNU Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013F (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Copyright (c) 2013-14 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.