---
title: Eboard 30  Analyzing procedures
number: 30
section: eboards
held: 2018-04-13
link: true
---
CSC 151.01, Class 30:  Analyzing procedures
===========================================

_Overview_

* Preliminaries
    * Notes and news
    * Upcoming work
    * Extra credit
    * Friday PSA
    * Questions
* Quiz
* Lab
* Debrief?

Preliminaries
-------------

### News / Etc.

* Warning!  Friday the 13th falls on a Friday this month.  Please be
  extra careful.
* Some of you have noted with concern that we did not get enough chance 
  to debrief on vectors or higher-order procedures.  If you'd like to
  ask some questions, I'll take questions about those issues until 9:00
  a.m. or so.

### Upcoming work

* [Lab writeup for class 30](../writeups/writeup30): Exercise 3
* Reading for Monday
    * [Project description](../assignments/project)
* [Flash Cards](../flashcards/flashcards11) due Wednesday at 9pm.
    * Optional.
    * Grade is percent of eight flashcard assignments you complete 
      (capped at 100%).
* [Assignment 7](../assignments/assignment07) due next Tuesday at
  10:30 p.m.
    * Let me know your partners!  (I may check in with you during class.)

### Extra credit (Academic/Artistic)

* Any one activity in the student research symposium next week.
* Water Dance performance at CERA on Saturday.
* Art and Science of field work Sunday at CERA.  RSVP necessary.  You
  should have received email.
* Medieval Improv concert Saturday at 7:30 p.m. in Sebring-Lewis.

### Extra credit (Peer)

* Drag show April 14

### Extra credit (Recurring peer)

* Listen to KDIC Wednesdays at 6pm - Witty banter with other 
  personalities and/or co-host.  Also Indian, Arabic, and Farsi music.  
  (Up to two units of extra credit.)
* Peer editing with SS.  Talk to SS about the details.  Make your
  English Lit more literate.

### Extra credit (Misc)

* Host one or more prospective students.  (I think there's one visit
  weekend left.)

### Other good things

### Friday PSA

* You are thoughtful, intelligent, caring people.  I am fortunate to
  be able to teach you.
* Because you are thoughtful, intelligent, and caring, you have the
  capability to do advance planning.  Reflect what is right for *you*
  this weekend and try to stick to your plan.
    * Excess is rarely the right thing.
* If you choose to cohabit, planning can also be good.  But remember that
  no matter what, consent is necessary.  Don't damage another human being.

### Questions

_Why do we need four cases for `number-tree-largest`?_

* What's the largest value in the empty tree?  There are no values in
  the empty tree, so it's a meaningless question.
* Oh!  Perhaps my base case is "It's a leaf."
* What are the possibilities if it's not a leaf?
    * Empty left, Nonempty right
    * Nonempty left, Empty right
    * Nonempty left, Nonempty right
* I'm not sure that there's one common thing for all three cases.
    * Well, we do want maxima, but slightly different computations.

```
(define number-tree-largest
  (lambda (ntree)
    (cond
      [(leaf? ntree)
       (contents ntree)]
      [(empty? (left ntree))
       (max (contents ntree)
            (number-tree-largest (right ntree)))]
      [(empty? (right ntree))
       (max (contents ntree)
            (number-tree-largest (left ntree)))]
      [else
       (max (contents ntree)
            (number-tree-largest (left ntree))
            (number-tree-largest (right ntree)))])))
```

_Trees seem pointless.  Why are you making us do them?  Are you just cruel?_

* Yes, I am cruel.  But, more importantly, trees lead to some more interesting
  and more complicated patterns of direct recursion.
* Some kinds of trees end up being particularly useful.
     * Binary search trees make searching *much* faster.
     * If we have 1000 things in a vector, it will take us about 1000
       comparisons to discover that something is not in the vector.
     * If we have 1000 things in a balanced binary serach tree, it will
       take us 
         * about 500
         * the depth of the tree (log)
         * um
         * *TEN*, more or less
* We represent many kinds of data as trees, such as Web pages.

_Should we always convert our data to a tree if we want to search it?_

* No, there's a tradeoff involved.  If you only want to search once or
  twice, it's expensive.

_When we take the quiz, can we assume that `left`, `right`, `contents` 
and others of that ilk are in the library?_

* Yes.

_Will we always have to copy and paste the tree code?_

* No.  You can use `(require csc151/trees)`, or at least I think you can.
* We intentionally keep the tree code separately from the primary code.

Quiz
----

Remember!  If you finish early, relish the opportunity to have a few
minutes of quiet.

Lab
---

Writeup: Exercise 3

* Don't forget to update `list-append` to count the calls to `cons`,
  `car`, and the rest.
* We'll talk on Monday about why you get results like 28 calls to `cons`
  for a list of length 8.

Debrief
-------
