Skip to main content

CSC 151.01, Class 52: An Introduction to Sorting

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
    • Friday PSA
  • Mentor evaluations!
  • Lab
  • Discussion of sorting

News / Etc.

  • Continue partners.
  • It’s National Pipe Cleaner day! (No, not really.)
  • Next week
    • Monday: We talk about your projects from the design perspective.
    • Tuesday: We talk about your code.
    • Wednesday: We talk about the exam and the class as a whole.
    • Friday: You fill out end-of-course evaluations and get your final PSA.
  • Monday is a celebration of your work. What do you want as food?
    • “Candy sushi”
    • Fruit
    • Doritos
    • Brownies
  • A sponsor is offering to pay for Grinnell Women in Computing shirts for anyone who commits to wearing them. https://grinnell.formstack.com/forms/women_in_computing_shirts
  • We’re doing a lot today. I’d like you to do a bit of the lab, but then we’ll come back to a general conversation about sorting.

Upcoming Work

  • No more lab writeups.
  • No more quizzes.
  • One more reading: Sorting
  • Exam 4 due Tuesday.

Extra credit (Academic/Artistic)

  • CS Table, Tuesday: CS-related comic strips.

Extra credit (Peer)

  • MLC Open Night Mike TONIGHT 7pm Bob’s. $200 tab.
  • Grinnell Monologues is performing this Friday in Main Lounge at 7:30 p.m.
  • Drill Team Show, Friday, May 5, at Triple V stables. The other side of the golf course. Free rides (cars, not pony) to the event!
  • Swim Team hosts Triathalon this weekend (running 3 miles, biking 13 miles, swimming 1/2 mile). Participate or help out.
    • Sam will reimburse your admission fee.
  • GSEA (Grinnell Space Exploration Agency) is launching a weather balloon on May 7th at 5:30AM. The balloon will go to almost-space and take pictures. It’ll also tell us about its location and the temperature of the air around it as it rises. We’re inviting people to come see the launch, if they want to come (despite the fact that it’s at 5:30AM).
  • Baseball, Sunday, May 7 (Senior Day)
  • Advanced Performance Performances Sunday at 7pm in the Wall

Other good things to do

  • Collegium Sunday at 2 p.m.
  • Take care of yourselves.

Questions

I’ve figured out what the whatzitdo does, but have no idea why anyone
would want such a procedure. What should I do?
If you can send me an explanation of what it does, I’ll give some examples of how it might be used.
I came up with an answer to the make-selector problem much more quickly
than I expected. What am I doing wrong?
If you’ve mastered higher-order procedures and local procedures, make-selector should be straightforward.
Of course, that’s my goal for every problem.
You look slightly less disheveled than normal today. What’s up?
I’m giving a talk to the Duke TIP kids.
Any hints on the vector-reverse! problem?
Write out the steps you expect to happen.
Think about what tools help with that.
Any hints on the vector->tree problem?
Recurse on both the left and right subtrees
Any hints on the index-of-extreme problem?
Solve if for “index of the alphabetically last string” and then generalize.
Write down steps in an example by hand.
What should happen if I do (define select-even (make-selector even?)) and
then (select-even (list "a" 2 3))?
It should crash.
How does that tree-utils.rkt thing work?
Instructions in exam. I’ll demo.
Open terminal window. Type raco link /home/yourusername/Desktop
Why are you making us use a separate file?
We like to torture you.
It’s good practice. (The separate file, not the torture.)

Mentor Evaluations

  • Help make our mentors and tutors even better at what they do.
    • If you are continuing in CS, think about applying to be a mentor or tutor or grader (but after you finish CSC 161)
  • When you are done filling out the form, start the lab.

Lab

  • Work until 9:35.
  • No, you won’t get very far in fifteen minutes. But you’ll get some foundation of what’s supposed to happen in binary search.
  • It may even help on an exam problem.

Quick check

Linear search: Keep track of position: 0, then 1, then 2, then 3, …

[0:aardvark, 1:bat, 2:chinchilla, 3:dingo, 4:emu, 5:flying fox
 6:gibbon, 7:hippo, 8:iguana, 9:jackalope, 10:koala, 11:lemur,
 12:moose, 13:nothing, 14:octocat]

Binary search: keep track of the lower bound and upper bound of the region of interest. Look in the middle.a * Found the value you were looking for. Done. * Determine whether the value you are looking for is on the left or the right and move the bounds * Left: Change upper bound to midpoint - 1 * Right: Change lower bound to midpoint + 1 * If it’s not there, we stop. We know it’s not there when the lower bound and upper bound are the same, and we failed that first test. * Alternately: If lower bound is greater than the upper bound, it’s not there.

  • Initially: lb is 0, ub is 14, middle is 7
  • hippo comes before lemur, so lb is 8, ub is 14, middle is 11 (quotient (+ ub lb) 2)

What exam problem will these ideas help with?

  • Maybe selection sort
  • Between 1 and 6, inclusive
  • Helps with vector to binary trees

Friday PSA

  • Why I make these PSAs.
  • Take care of yourselves.
  • Consent is absolutely necessary.

Sorting out sorting