[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Exams] [Examples] [Book] [Tutorial] [API]

Back to The Design of Lists. On to Project Discussion.

**Held** Monday, October 25, 1999

**Overview**

**Notes**

- I'm returning exam 2 today.
- I'll give you about ten minutes to look over your exams
- Then we'll go over them.

- Don't forget to get interfaces and stub classes to me by 9 a.m. Wednesday.
- Because of the difficulties many of you have had with running time analysis, I've decided not to grade assignment 3. Sorry for the late decision. I'm happy to go over your assignments on an individualized basis, if you'd like.

**Contents**

**Handouts**

**Summary**

- Discussion of exam 2

- Some basic data:
- Median grade: 86
- Mean grade: 80
- Information on times included in the notes on the exam
- A number of you spent approximately 10 hours on the exam. That's more than I'd hoped for. What were my expectations? That A, B, and D would each take 30 minutes or so (along with some passive rumination about B) and that C would take about an hour.

- A minor note:
- Some of you did not put your answers in order, in spite of a requirement on the exam that you do so. Please make sure to do so in the future.

- Two particularly important issues:
- I noticed a few cases in which answers were quite similar, not
only in the technique used but also in the mistakes made. I'm
hoping this was just coincidence.
*Do not work together on exams or otherwise share your work.* - Many of you are taking code from elsewhere and failing to cite
in, in spite of instructions on the exam and the introductory
handouts.
*It is a violation of Grinnell's academic honesty policies to use the work of others without citing it.*For this exam, I've treated such violations as a ``lack of craft''. Please be more careful in the future.

- I noticed a few cases in which answers were quite similar, not
only in the technique used but also in the mistakes made. I'm
hoping this was just coincidence.
- When we go over the exam in class, I may ask for volunteers to come up to the front of the room. In general, you do not need to volunteer if you got over 15 on a problem (nor should you call out answers).

- What is the value of 1 + 2 + ... +
*n*? (I'll go through the proof for this one.) - What is the value of 1 + 1/2 + 1/4 + 1/8 + ... +
1/2
^{k}? - What is the value of n*(1 + 1/2 + ... + 1/2
^{k})? - What is the value of 1 + 2 + 4 + 8 + 16 + ... + 2
^{k}?- Hint: Use the previous formula

- Thinking about the problem: We have the formula
f
_{1}(*n*) = c_{2}*n*+ f_{1}(*n*/2). What does the formula suggest about the design of the code (i.e., what the code does)? Consider each part. - Now, let's try the more formal analysis.

- What were the greatest difficulties students had with this problem?
- The sum mentioned above
- ``Dropping constants'', which sometimes went so far as to
drop a term involving
*n*. Most of the time, when we `` drop constants'', we simply turn them into the value 1.

- A few related questions
- if f(
*n*) = f(*n*/2) and f(*1*) is 1, what does this say about f? - if f(
*n*) = f(*n*-1), what does this say about f?

- if f(

- Most of you got this substantially right. The greatest difference between two values in a collection is the difference between the largest and smallest values in that collection. Hence, we can find the largest in O(n) and the smallest in O(n) and subtract them.

- I was surprised to see that some of you decided to rewrite partition from scratch rather than use the version in the book. Often, those who did so took particularly long to do the problem.
- One of the more common mistakes was to substitute
`equals`

for`lessEqual`

, as in__protected____int__partition(__int__lb,__int__ub, Comparator compare)__throws__IncomparableException { Object pivot =__this__.get(lb);**// X: A to get**__int__first = lb;__int__last = ub;__while__(first < last) {__while__( (compare.lessThan(pivot, get(last))) && (first < last) ) { last--; } // while there are big elements on the right__while__( compare.equals(get(first), pivot) && (first < last) ) { first++; } // while there are small elements on the left__if__(compare.lessThan(get(first),get(last) { swap(first,last); } } // while__this__.swap(lb,first);__return__first; } // partition - Will this still work? Will it work differently?

- I took off a little if you used
`objects[i]`

rather than`get(i)`

. Let's brainstorm reasons to prefer the second over the first.

- A casual analysis was fine.
- Note that the 2 in f(
*n*) = c + 2*f(*n*/2) was particularly important.

- Random selection
- Least difference
- Integer comparator

Tuesday, 10 August 1999

- Created as a blank outline.

Monday, 25 October 1999

- Filled in the details.

Back to The Design of Lists. On to Project Discussion.

[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Exams] [Examples] [Book] [Tutorial] [API]

**Disclaimer** Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/99F/Outlines/outline.31.html

Source text last modified Mon Oct 25 09:46:24 1999.

This page generated on Mon Oct 25 09:48:18 1999 by Siteweaver. Validate this page's HTML.

Contact our webmaster at rebelsky@grinnell.edu