Section Readings: 1.2
Problem 1. (Closest Pair Distance) Write a Point2D client ClosestPairDistance that takes an integer value N from the command line, reads N points (each de ned by a pair of double values) from standard input, and prints the distance separating the closest pair of points.
java ClosestPairDistance 100 < points.txt
Problem 2. (Intersecting Intervals) Write an Interval1D client IntersectingIntervals that takes an integer value N from the command line, reads N intervals (each de ned by a pair of double values) from standard input, and prints the number of intervals that intersect.
java IntersectingIntervals 100 < intervals.txt 4023
Problem 3. (Circular Shift) A string s is a circular shift of t if it matches when the characters are circularly shifted by any number positions; eg, ACTGACG is a circular shift of TGACGAC, and vice versa. Detecting this condition is important in the study of genomic sequences. Write a program CircularShift that prints true if two strings s and t speci ed on the command line are circular shifts of one another, and false otherwise. Hint: The solution is a one-liner with indexOf(), length(), and string concatenation.
java CircularShift TGACGAC ACTGACG true
java CircularShift TGACGAC GACGAC false
java CircularShift TGACGAC TGACGAC true
Problem 4. (Instrumented Binary Search) Write a program InstrumentedBinarySearch that uses a Counter to count the total number of keys examined during all searches and then prints the total after all searches are complete. Hint: Create a Counter in main() and pass it as an argument to rank().
java InstrumentedBinarySearch tinyW.txt < tinyT.txt
Files to Submit:
Spring 2015 1 of ??