EBoard 29: Tree Recursion

This class will be recorded! Its use is limited to members of the class. Please do not share with others.

Approximate overview

  • General administrative stuff [~10 min]
  • Q&A [~10 min]
  • Quiz [~10 min]
  • Lab [~60 min]

Administrative stuff

Notes and news

  • Revision to schedule/syllabus
    • Down to five MPs (A: 1 fewer E, B,C: 1 fewer M)
    • Extension to MP5 until Friday 10:30 p.m.
  • Review sessions for the next SoLA will be on Monday evening. (+1 token for reflections / don’t just report)
  • Still working on grading.
  • Additional office hours (email or DM to reserve times)
    • Friday, 1-2
    • Monday, 2:30-4:30
    • Tuesday, 2:30-4:30
    • Wednesday, 2:30-4:30
    • Thursday, 2:30-4:30
  • I’ll also continue to hang out on Teams and email when I can.
  • If you keep DrRacket running, I’d suggest you quit and restart, just so that you can see today’s opening screen. (At least today’s opening screen in the U.S.)
  • Reminder: Labs always begin with this term. If you don’t see “Fall 2020, Term Two” or something similar at the top, you probably have the wrong lab.

Tutoring reminders

  • Please use our tutors! They like to work.
  • Evening tutoring will be available
    • 8-10 p.m. Sundays through Thursdays
    • 3-5 p.m. Sundays
    • In the “Drop in tutoring” channel on the CS team.
    • Sam will generally not be available during these times.
    • We should have two evening tutors on Wednesdays.
    • Don’t forget to cite the evening tutors (and the individual tutors).
  • Sam is checking to see if they can be available Friday.

Upcoming activities

Info:

  • Attend (or watch recording within a day or so) and send a one-paragraph reflection asap afterwards.
  • Only those activities I list count.
  • But you can suggest others.
  • Links are in the Announcements channel.
  • Unless otherwise specified, these each earn one token.

Activities

  • 11:30 a.m. TODAY, 10 December 2020: SPARK Info Session
  • 12:00 m. TODAY, 10 December 2020: 2020 Choir Odyssey
  • 5:00 p.m. TODAY, 10 December 2020: MIST: The Mathematical Image Synthesis Toolkit. Sam’s research students. (+2 tokens, even if you critique their work)
  • 2:00 p.m. Friday, 11 December 2020: Newberry Library Talk.
  • 12:00 m. Monday, 14 December 2020: CS Table (I think)
  • 5:00 p.m. Monday, 14 December 2020: Mentor Session
  • 9:00 p.m. Monday, 14 December 2020: Mentor Session

Upcoming work

Mini Projects

Readings

Quizzes

  • Quiz Today: Tree basics
  • Quiz Tomorrow: Tree recursion

Other

  • SoLA 4 next Wednesday (note different day of week)

Q&A

Mini-Project 5

Can I use a token for an extension until Friday?

No. You get a free extension until Friday.

Can I use a token for an extension until Sunday?

I’d prefer that you did not, but yes.

Will there be mentors available Friday evening?

I’m seeing if I can arrange that.

Where should I put my helpers?

I like them at the top. But the bottom is fine, too.

How do I know if my randomness is computationally efficient?

Mental math. Ask evening tutors or Sam or classmates or ….

Administrative stuff

How do I see my grade on Gradescope?

Um, you don’t. You count what percent of labs, quizzes, and such you have credit for and compare to the guidelines in the syllabus.

Sorry for the confusion!

Other Questions

What should I do when my lab shows as gobbledygook?

File -> Save Other -> Save Definitions as Text …

You will almost always get gobbledygook if you use “Comment with boxes”

What if that doesn’t work?

Computers are evil. Contact Sam.

Is it okay if Gradescope says it’s too long?

I think so.

Can we still use comment with boxes?

Sure. I prefer #| ... |#, which seems safer.

Reading

Can you explain string-ci<=?

It’s just doing alphabetical comparison, as in a dictionary.

> (string-ci<=? "alpha" "omega")
#t
> (string-ci<=? "sam" "john")
#f
> (string-ci<=? "samr" "samuel")
#t

Can you go over the trace from the reading?

Sure.

Overview of binary search

    > Is the tree empty?

    > Is the value at the root (top) of the current tree?  
      If so, we're done

    > Is the value less than the root (top)?  (Alphabetically precedes)
      If so, look in the left subtree.

    > The value is greater than the root (top). (Alphabetically follows)
      Look in the right subtree.

Tree is not empty. Look at “Mongoose”. “Skink” comes afterwards, so we look to the right.

Tree is not empty. Look at “Pidgeon”. “Skink” comes afterwards. So we look to the right.

Tree is not empty. Look at “Yak”. “Skink” comes earlier. So we look to the left.

Tree is not empty. Look at “Skink”. We found it! We’re done.

Could you make that look more like normal traces?

    (bst-search '("Mongoose" L R) "Skink")
    ; Skink comes after Mongoose
--> (bst-search '("Pidgeon" L R) "Skink")
--> (bst-search '("Yak" L R) "Skink")
--> (bst-search '("Skink" L R) "Skink")
--> "Skink"

Could you trace the search for “Hippo”?

(bst-search '("Mongoose" L R) "Hippo")
; Hippo comes before Mongoose, look left --> (bst-search '("Iguana" L R) "Hippo")
; Hippo comes before Iguana, look loeft --> (bst-search '("Emu" L R) "Hippo")
; Hippo comes after Emu, look right --> (bst-search '("Gnu" L R) "Hippo")
; Hippo comes after Gnu, look right --> (bst-search empty-tree "Hippo"
; NOT THERE! --> #f ```

How did we know that “Hippo” is on the left?

The requirements of binary search trees.

  1. Everything on the left comes before the root. (or vice versa)
  1. Everything on the right comes after the root. (or vice versa)
  1. The subtrees are also binary search trees.

Could you go over the first self-check?

Sure.

We’ll get the same answer; we just do it in a different order.

As in the case of reduce, if we use +, it won’t matter. But if use - or other things, it can matter.

Do we count underlines in the size?

No. The “if it’s empty, use 0” says “count 0 for the underlines”.

There are no values in the empty tree.

Quiz

You know the drill.

Lab