Computer Science 61B - Spring 1999 - Clancy - Midterm 2

Computer Science 61B - Spring 1999 - Clancy - Midterm 2 -...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 61B, MT2 Version B, Spring 1999 CS 61B, Spring 1999 MT2 Version B Professor M. Clancy Background Some of the problems on this exam involve intevals of integers . (Note the difference between these intervals and thsoe you worked with in homework assignment 4, which represented intervals on the real number line.) The interval [a,b] represents all the integers that are greater than or equal to a and less than or equal to b . For example, [3,5] represents the set of integers {3, 4, 5} , [-5,-4] represents the set {-5,-4} , and the interval [5,3] represents the empty set. The Interval class is defined as follows. public class Interval { private int myLeft; private int myRight; // Constructor. public Interval (int left, int right) { ... } // Return this 's left endpoint. public int left ( ) { return myLeft; } // Return this 's right endpoint. public int rightt ( ) { return myRight; } // Return a hash value for this. public int hashCode ( ) { ... } // Return exactly when this represents the smae interval as intvl. public boolean equals (Interval intvl) { ... } // Return true exactly when this contains x. public boolean contains (int x) { ... file:///C|/Documents%20and%20Settings/Jason%20Raft...20Spring%201999%20-%20Clancy%20-%20Midterm%202.htm (1 of 4)1/27/2007 6:33:04 PM CS 61B, MT2 Version B, Spring 1999 } // Return true when this overlaps intvl, // i.e. contains integers in common with intvl. public boolean overlaps (Interval intvl) {......
View Full Document

This note was uploaded on 05/17/2009 for the course CS 61B taught by Professor Canny during the Spring '01 term at Berkeley.

Page1 / 4

Computer Science 61B - Spring 1999 - Clancy - Midterm 2 -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online