Skip to main content

CSC 151.03, Class 14: Discussion of exam 1

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
  • Common issues
  • Exercise 2
  • Exercise 6
  • Exercise 5
  • Exercise 4
  • Remaining issues

News / Etc.

  • New partners.
  • Please make sure to return your computer cards to the jar.
  • I’m glad to be back; I’m sorry that I missed classes.
  • 70 exams x 6 problems + admin x 5 min = approx 2400 minutes or 40 hours. I’ll get exams back to you next Monday.

Upcoming Work

Extra credit (Academic/Artistic)

  • CS Table, Tuesday: Casual chat
  • Google technical résumé talk, Tuesday at 4pm, Science 3821
  • Scholars Convocation, Thursday at 11am: Wilson Okello on “Living in the Wake of Crisis”

Extra credit (Peer)

  • Upcoming Women’s soccer matches

Extra Credit (Misc)

None at the moment.

Other Good Things

  • Volleyball Wednesday
  • GHS Homecoming - North of GHS on Thursday at 4pmish.

Questions

There’s something weird on the lab writeup. Can we look at it?
Check your guard for the unknown case. It should probably be something like (not (real? (cadr entry))) rather than (equal? (cadr entry) "").
Problem 4 of the assignment suggests that we should test it on other
schedules. Does that mean we should write our own?
Yes.

Common issues

  • When to ask for help. Early and often.
  • Work on the six-P style documentation. The form is important. Postconditions tell you not just type, but value.
    • Postconditions are what the procedure is guaranteed to do
  • What got extra credit?
    • Really nice tests.
    • The occasional good joke.
    • Some implementations that made me say “cool”
  • “There’s more to life” belongs only on your cover sheet.
  • I really do care that you use the template file.
  • Formatting. Please hit ctrl-i before submitting.

Problem 2

We’ll look at documentation and code.

;;;   (length newlst) < (length lst) ; BAD POSTCONDITION
  • We can’t guarantee that. start could be 0 and finish could be (length lst)
  • It’s insufficient. We could, for example, just filter out some elements and achieve the goal. We could just drop a few elements. We could make a list of zeros. We could return null. (define sublist (lambda (lst start finish) null))

Thinking about edge cases is important for preconditions. Can the original list be empty? What is the smallest/largest value for start? What is the smallest/largest value for finish?

Problem 6

We’ll walk through one approach to solve it. There were others.

Problem 5

We’ll walk through one approach to solve it. There were others.

Problem 4

What should you test? What are your answers? (I’ll then add my own.)

  • [An alternate to Is this the list I get? is to ask whether the sum is correct.]
  • If you remove all the odd numbers from a list of odds numbers, you should get the empty list.
  • All even numbers.
  • Alternating odd and even numbers.
  • Only 0’s. Lots of numbers, including 0.
  • Big numbers (highly positive, highly negative)
  • Evens at the front
  • Odds at the front
  • Evens in the middle
  • Odds at the middle
  • Evens at the end
  • Odds at the end
  • Inexact numbers; NO! The preconditions forbid this. Tests on things that don’t meet the preconditions are dangerous.
  • Positive and negative (mixed)
  • Really big lists
    • (check-equal? (sort (remove-odds (iota 10000))) (map (section * <> 2) (iota 5000)))
    • (check-equal? (remove-odds (append (make-list 10000 5) (list 2) (make-list 20000 -3))) (list 2))
  • Duplicate values

We’ll continue with the documentation.

Why is this not a sufficient postcondition?

;;; Postconditions:
;;;   (length no-odds-lst) <= (length lst)