The Sorting Hat

Jed Rembold

April 17, 2026

Happy Penultimate Friday!!

Quick Announcements

  • Midterm 2 results out
  • Grade Reports out this weekend
  • Enigma due on Monday night!
  • Introducing the last project on Monday
    • NO VIDEO

Midterm 2 Debrief

  • Final breakdown:
    • Max: 105%
    • Average: 70.87%
    • Median: 70.45%
    • St Dev: 21.7%

Exam Corrections

  • Given this situation, I am going to offer some exam corrections
  • If you lost points on a non-extra credit problem, you can earn up to 50% of the lost points back by:
    • Creating a Trilogy Portfolio: Collecting learning objectives, identifying past examples in in-class work and in your work, synthesizing why you didn’t make the connections and how to improve going forwards
    • Creating a new problem and solution: New problem should address at least 80% of your identifying learning objectives, and your solution should be correct. Must also write a “Design Rationale” paragraph about why you made the choices you did in writing your solution.
  • Full guide can be found here
  • Must be completed for each problem you want points back on
  • Due midnight of May 1st. Past that point, you will not be able to submit.
  • 100% optional, and you can not earn over a 100% by doing corrections

Daily LO’s

  • How does selection sort operate?
  • How can we get an idea for how an algorithm will scale just by looking at the code?
  • What is Big-O notation?
  • Can we identify examples of Big-O notation?

Group Problems

Problem 1: Sort It!

  • I am distributing small stacks of playing cards to each of your groups
  • Designate:
    • The processor: the one pointing at the current card that is being looked at
    • The memory: the one whose left and right hands will mark the special positions
    • The counter: the one tallying how many cards have been looked at
  • Shuffle the cards and deal out 5 in a row
    • Sort them according to selection sort, following your roles
    • How many cards did you look at? Does that agree with what you’d have thought?
  • Shuffle all the cards back together and deal them all out.
    • Sort again. How many cards were looked at this time? Does this agree any better?

Problem 2: Real-World O

  • We are going to cycle through some real-world scenarios here
  • For each, you’ll have about 2 minutes to discuss with your group what Big-O scaling you think the process would involve

Problem 2a: The Librarian

  • Checking a shelf of books to see if any have a torn cover.

Problem 2b: The Mechanic

  • Grabbing the largest wrench in a toolbox organized with molded slots for each tool.

Problem 2c: Favorite Movies

  • Finding 3 people in a class who all share the same favorite movie.

Problem 2d: The Warehouse

  • Retrieving a part from the bin labeled “Part #105” in a large, organized warehouse.

Problem 2e: The Wedding Planner

  • Creating a seating chart that ensures that no “mortal enemies” are seated together at the same table.

Problem 3: Algorithm Archaeology

  • You have written a lot of code over the course of the semester!
  • The following slide will have a handful of target “bounties”
  • Your task is to fine examples of each bounty in code that you or someone in your group has written over the course of the semester.
  • Be prepared to defend your choices to another group!

Problem 3: The Bounties

  • Find a snippet that looks like a single \(\mathcal{O}(N)\) loop but is actually \(\mathcal{O}(N^2)\) because of a built-in Python function.
  • Find an \(\mathcal{O}(1)\) operation
  • Find an \(\mathcal{O}(N^2)\) operation that does not use two nested for loops
  • Find an \(\mathcal{O}(N)\) operation that finishes in \(\mathcal{O}(1)\) under special conditions
  • Find the heaviest code you wrote this semester. How does it scale?

Problem 4: Designing a Disaster

  • This is a coding problem!
  • Linear search is usually \(\mathcal{O}(N)\) in the worst case situation.
  • Design a searching algorithm that runs in \(\mathcal{O}(N^3)\)
    • It must still work! That is, it must still return a correct answer.
// reveal.js plugins // Font Awesome Characters