Skip to main content

CSC 151.01, Class 18: Recursion basics lab

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
  • Lab
  • Debrief

News / Etc.

  • New partners.
  • Please make sure to return your computer cards to the jar.
  • Exam 2 distributed. We’ll talk about it in a few minutes.
  • It appears that some of you have ignored the instructions and have decided that the appropriate approach to homework is to say things like “You solve problems 1-3 and I’ll solve problem 4-5”. So, I’ll make it easy for you: If I find out you’ve done that, you get a zero on the homework.
  • Note that the graders do want to run your programs. If they cannot just load the code you’ve provided into DrRacket, you will likely lose significant numbers of points.
  • You did have an obligation to show your work on problem 4. The following is unacceptable.
    • I pick “there”, “was”, and “has” to check the common connections in different files. I found through the order of the high frequency words change, the results have lots of same words. For example, after the word “was”, “to”, “a” “the”, and “that” have appeared in most of the following-word. after the word “there”, “was” and “a” are most frequently appeared.
  • I still have not had time to grade your quizzes. You may get them back on Friday.
  • Please discuss which switching format you and your partner will use
    • Switch every ten minutes
    • Switch midway through class
    • Switch every problem

Upcoming Work

  • No writeup for class 16.
  • No writeup for class 17.
  • Writeup for class 18 due Friday at 10:30 p.m.
  • Reading for Friday’s class: Recursion with helper procedures
    • Not yet ready.
  • Exam 2 prologue due Friday at 10:30 p.m.
  • Exam 2 due Tuesday at 10:30 p.m..
  • Exam 2 cover sheets due Wednesday at the start of class
  • Exam 2 epilogue due Wednesday at 10:30 p.m.

Extra credit (Academic/Artistic)

  • TODAY, 5pm, Mary Beth Tinker Talk
  • Thursday evening movie about survivor’s experiences

Extra credit (Peer)

  • Men’s Soccer vs. Cornell Wednesday at 4:30
  • Volleyball vs. Beloit, Friday at 7:00 p.m.
  • Women’s Tennis vs. St. Norbert, Saturday at 9:00 a.m.
  • Volleyball vs. Lake Forest, Saturday at 1:00 p.m.
  • Women’s Tennis vs. Ripon, Saturday at 3:00 p.m.
  • Nice Fish. This weekend. Marvel at the lights.

Other good things

  • Football, Saturday at 1:00 p.m.
  • Neverland Players, this weekend.

Exam 2

  • We’ll go over the parts of the exam.

Questions on the exam

On problem 1, can I use recursion?
Yes. But you need not. You could also use map and other stuff.
On problem 1, should the husk call the kernel?
Certainly.
Can I use recursion on problem 2?
No. Use map.
Can I use recursion on problem 7?
No. There is no problem 7.

Homework 5

I used made-up books. Should I fix that?
Yes.

Lab

> (+)
0
> (*)
1
; Ask yourself why

Is there a way to see what parameters our recursive procedure is
being called with?

(define proc (lambda (params) (write (list ‘proc params)) (newline) ; The body follows ))


Debrief
-------

Your writeup is exercise 7.

(define my-length (lambda (lst) ; (display (list ‘my-length lst)) (newline) (if (null? lst) 0 (+ 1 (my-length (cdr lst))))))

(define largest0 (lambda (lst) ; (display (list ‘largest0 lst)) (newline) (if (= (my-length lst) 1) (car lst) (max (car lst) (largest0 (cdr lst)))))) ; Whoops! That does a lot of calls to my-length.

(define largest1 (lambda (lst) ; (display (list ‘largest1 lst)) (newline) (if (null? (cdr lst)) (car lst) (if (> (car lst) (largest1 (cdr lst))) (car lst) (largest1 (cdr lst)))))) ; Do you see any problems? What if lst is organized largest to ; smallest? What if lst is organized smallest to largest.