# Class 27: Detour: Intersection

Back to Local Procedure Bindings. On to Pairs and Pair Structures.

Held: Monday, 13 October 2003

Summary: Today we consider the problem of intersecting two lists in some depth.

Related Pages:

Assignments

Notes:

• Are there questions on the lab on local procedure definitions?
• Beware! Friday the 13th falls on Monday this week.
• A friendly reminder: Read the whole problem before beginning. Many problems have guidelines to follow or helpful suggestions.
• Today's topic started as pairs and pair structures. However, a question on the laboratory led to a discussion of the problem of intersection.

Overview:

• The problem of intersecting two lists.
• Formalizing the problem.
• A simple solution.
• Improving the solution: Eliminating duplicates.
• Detour: A strange solution.
• An alternate strategy: Permitting certain duplicates.

## The Problem of Intersection

• The intersection problem from the laboratory on local procedures is an interesting one.
• What should the documentation look like?
• Some cautions:
• How do we formally represent the meaning of intersection (or "appears in both lists") for someone who doesn't understand such terminology.
• Can a value be repeated? If it's repeated in both constiuent lists? If it's repeated in only one? If it's repeated in both?
• Can other values appear in the result?
• Observation: If we don't want repeated appearances (or if we want duplicate appearances), it may be helpful to delete things.
• Look at our sample code for more details.

## History

Thursday, 28 August 2003 [Samuel A. Rebelsky]

• Created automatically.

Back to Local Procedure Bindings. On to Pairs and Pair Structures.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue Dec 9 13:59:46 2003.
The source to the document was last modified on Mon Sep 1 13:30:51 2003.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2003F/Outlines/outline.27.html`.

You may wish to validate this document's HTML ; ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu