EBoard 37: Searching and analysis (Section 3)

Warning! You are being recorded and transcribed, provided the technology is working correctly.

Approximate optimistic overview

  • Administrivia
  • Quick academic honesty commentary
  • Questions and answers
  • Lab

Administrative stuff

Introductory notes

  • Candy
  • Please plan to attend class next Wednesday for project presentations.
  • Please plan to attend class next Friday for wrapup activities.
  • Our graders expect to finish grading the second redo of MPs 4 and 5 and the first redo of MP6 graded by Sunday night.
  • Do you get the csstudents email?

Upcoming activities

Scholarly

Artistic

  • Any day it’s open. GCMoA. BAX
  • Friday, 2 May 2025, 7:00–9:00 p.m., Sebring-Lewis. Silent Films with Improvised Scores
  • Friday, 2 May 2025, 7:30–8:30 p.m., Flanagan. Dance Ensemble/ACTivate: A Rebours
  • Saturday, 3 May 2025, 2:00–3:00 p.m., Flanagan. Dance Ensemble/ACTivate: A Rebours
  • Saturday, 3 May 2025, 7:00–8:00 p.m., Wall. Infinite Coincidence Improv Show
  • Thursday, 8 May 2025, 7:30–10:00 p.m., Sebring-Lewis. Symphonic Band Concert

Multicultural

  • Friday, 2 May 2025, 4:00–5:00 p.m., HSSC N1170 (Global Living Room). Middle of Everywhere: Brazil
  • Friday, 2 May 2025, 5:00 p.m., HSSC N 1164. ISO Scrap Book
  • Sunday, 4 May 2025, 2:00–8:30 p.m., Cleveland Beach. (Estimates.) Holi

Peer

Musical, theatric, sporting, and academic events involving this section’s students are welcome.

  • Read articles by your fellow CSC-151 students and comment on them online. This is the last week of normal S&B articles!

Wellness

  • When and where they usually occur. Badminton Club, Brazilian Jiu-Jitsu, _HIIT Training, Nerf at Noyce, Yoga.
  • Thursday, 8 May 2025. 4:30–6:30 p.m., Off Campus. Forest Bathing.
    • Sign ups are required.
  • Tuesday, 13 May 2025, 5:00–6:00 p.m., HSSC Atrium. Therapy Dogs.
  • Tuesday, 13 May 2025, 7:15–8:15 p.m., HSSC Atrium. Therapy Dogs.

Misc

  • Friday, 2 May 2025, 3:30–5:00 p.m., Burling Digital Studio. Vivero End-of-Year Showcase
  • Friday, 2 May 2025, 5:00 p.m., Natatorium. CS Picnic
  • Sunday, 4 May 2025, 7:30–8:30 p.m., Science 3819. Mentor Session: SoLA 4
  • Wednesday, 7 May 2025, Noon–1:00 p.m., HSSC A2231 (Auditorium) Community Forum
    • “Weekly discussion on legal protections and recourse on issues that higher education and Grinnell College face.”
    • Also online.
    • Surviving the summer.

Other good things

These do not earn tokens, but are worth your consideration.

  • Saturday, 3 May 2025, Noon, Baseball field. Baseball vs. Knox (senior day)
  • Saturday, 3 May 2025, 2:30 p.m., Baseball field. Baseball vs. Knox

Upcoming work

  • Sunday, 4 May 2025
  • Monday, 5 May 2025
    • SoLA 4 released!
    • Topics from Phase One (4): Collaboration, Decomposition, Lambda-free anonymous procedures (aka cut and compose), Primitive types
    • Topics from Phase Two (6): Conditionals, Documentation, Ethical considerations, Lists (and “the big three”), Program style, Testing
    • Topics from Phase Three (5): List recursion, Local bindings, Numeric recursion, Vectors, Randomness
    • Topics from Phase Four w/prior quizzes (3): Data abstraction, Dictionaries, Higher-order programming
    • Topics from Phase Four already covered (1): Tree recursion
    • Topics from Phase Four to be covered today (2): Running time, Searching
  • Wednesday, 7 May 2025
    • Project presentations.
  • Friday, 9 May 2025
  • Friday, 16 May 2025 (5pm)
    • Submit final redo for MP1 on Gradescope
    • Submit final redo for MP2 on Gradescope
    • Submit final redo for MP3 on Gradescope
    • Submit final redo for MP4 on Gradescope
    • Submit final redo for MP5 on Gradescope
    • Submit final redo for MP6 on Gradescope
    • Submit final redo for MP7 on Gradescope
    • Submit SoLA 5 on Gradescope

Friday PSA

  • You are awesome. Please remain so
  • Detour: Weekend Harris and Gardner
  • Moderation
  • Consent is essential, but not sufficient

Academic honesty

The Dean’s office has asked us to remind you about College academic honesty policies and about our course policies on the use of generative AI.

If you discover evidence that a student may have violated either the college academic honesty policy or the relevant academic honesty policy for your course/assignment, you must report that violation to the Committee on Academic Standing (CAS) for review.

Just in case it’s not clear already:

  • You may not use a generative AI tool to help you do your work in this class. In particular, you may not have a tool generate code for you for mini-projects, learning assessments, reading responses, meta-cognitive reflections.
  • You may not use a generative AI tool in any way for your SoLA responses.
  • In writing SoLA responses, you may rely only on yourself, your notes, my course Web site, the DrRacket reference, and DrRacket.
  • If you refer to my site or the DrRacket reference, you must cite your source (and cite it clearly).
  • If you feed course materials to a generative AI tool for other purposes (e.g., to get a summary or to generate problems), you must ensure that it does not use the course materials as training data. Otherwise, you are violating copyright.

Questions

Administrative

Can I reflect on S&B articles from past weeks?

Nope. Only the current week.

Is there a limit to the number of tokens I can earn in a week?

Yes. Five.

Project

Running time

Can we go over the self check?

Certainly. We’ll do it as a quick TPS exercise.

Constant: Independent of the “size” of the input.

Linear: As the size of the input goes up, the number of steps goes up correspondingly (e.g., if we double the input size, we approximately double the number of steps).

cdr - Constant. Throwing away the first element should not depend on the number of elements in the list.

cddr - Constant. Two constant operations are still constant.

(list-ref lst n) - Linear in n because we have to keep taking the cdr of the list n times.

(vector-ref vec n) - Constant. Sam said that we can access the value directly and the size doesn’t matter. (Experiments confirm this.)

(map fun lst) - Linear in length of list. We have to apply the procedure to each element; if we add elements, we have more steps to do.

(range n) - Linear in n. The have n elements in the list, so as n increases, the number of times we call cons to build the list increases directly.

Have we encountered any examples of quadratic time algorithms yet?

Yes. Many of the list recursive algorithms that use length to determine if we have only one element end up being quadratic.

What exactly does less-equal? check?

It depends on what kinds of values we’re storing and what order they’ve been stored. It hould correspond to the order they’ve been stored.

For numbers, it usually checks if one number is less than or equal to another number. For strings, it normally checks if one string comes before another alphabetically (as determined by string-ci<=?).

Can we go over the self check?

Certainly. TPS! (I’ve also added a question.)

a. Explain the role of the less-equal? in binary-search.

We compare the sought key to the key of the middle element, which lets us determine whether we’re found that key or need to search in the left half or the right half.

As Sam just said, we know that the elements are ordered by less-equal?.

b. In binary-search, how do we know if two values (a and b) are equal?

If a is less than or equal to b and b is less than or equal to a, then a equals b. (For our particular code, we say that if key is less than or equal to middle-key and middle-key is less than or equal to key, than key = middle-key.)

We shouldn’t use equal?. It’s not in the one on the reading, and we’re trying to use that one. Or … some versions of less-equal? give a different notion of equality. For example string-ci<=. (equal? "Lilli" "lilLI") returns false. However (and (string-ci<=? "Lilli" "lilLI") (string-ci<=? "lilLI" "Lilli")) returns true.

c. Explain the role of midpoint, middle-element, middle-key, which are bound in the let* of binary-search.

midpoint - the index of the middle of the section of interest.

middle-element - the value at that index

middle-key - the key of that element (e.g., the first name if we’ve sorted by name and are searching by name)

d. Describe what lower-bound and upper-bound represent.

They represent the area of the vector that we’re searching. Initially, they represent the whole vector. As we look in the middle, we can usually throw away about half of the elements in the area we’re searching.

lower-bound is inclusive. That means that we (usually) need to consider the value at index lower-bound.

upper-bound is exclusive. This means that we should not consider the value at index upper-bound (but should consider things with smaller indices)

e. Describe why and how the upper-bound of helper search-portion changes when the key we’re looking for is less than the middle key. (If it doesn’t change, explain why not.)

We use midpoint.

We do not use (- midpoint 1) because the upper-bound is exclusive. It won’t look at midpoint based on our policy. If we set upper-bound to (- midpoint 1), that says “we’ll never look at the value at position (- midpoint 1), and we know nothing about the value at the position.

f. Describe why and how the lower-bound of helper search-portion changes when the key we’re looking for is greater than the middle key. (If it doesn’t change, explain why not.)

We use (+ midpoint 1) rather than midpoint because the lower-bound is inclusive, and we know that the value at midpoint is not what we’re looking for.

g. If we double the length of the vector, what is the worst case effect on the number of recursive calls in binary-search?

It’s just one more. In that one more, we cut it in half so it’s back to the original size.

Lab