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
Unformatted text preview: CS51 Assignment 1: Trees, Trees, Trees Due: Friday, 13 February 2009 at 5:00 PM Total Points: 50 (including 10 style points) In this assignment you will get practice with Scheme and recursion by working with trees in a couple different forms. 1 Setup To complete this problem set you will need DrScheme 4.1.4 and the asst1.scm file that we have provided at http://cs51.seas.harvard.edu/docs/asst1.scm. Make sure the language is set to Intermediate Student. If you have any questions on how to work with DrScheme, please refer back to the zeroth assignment, post to the bulletin board, or ask a TF. 2 Style For this and all subsequent assignments, a substantial portion of your grade is based on style. Remember to consult the CS 51 style guide on the course website at http://cs51.seas.harvard.edu/docs/style.pdf if you have any doubts about what con- stitutes clear, well-written code. Even if you dont have specific questions, be sure to review the style guide to refresh your memory! 3 Testing your code How do we know when a program is correct? That is, how can we ensure that the code we write will do what we intend it to do? We can read it carefully, 1 but thats usually not enough. We can try to prove it correct, but for most programs thats too difficult to do. We probably have to write some tests. 1 Or in some cases, ask someone else to read it carefullybut not in CS51. 1 4 TREES CS51 Assignment 1: Trees, Trees, Trees Recall that we introduced the function check-expect in the last problem set. We expect that you will find it necessary to use tests to verify the correctness of your code. Please be sure to submit these tests with your assignment. Still unsure of what a test might look like? Suppose we want to test inside-unit-circle? from the previous problem set. Using check-expect , we might write: ( check-expect ( inside-unit-circle? 0 0) true ) ( check-expect ( inside-unit-circle? .5 .4) true ) ( check-expect ( inside-unit-circle? 1 0) true ) ( check-expect ( inside-unit-circle?-1 ) true ) ( check-expect ( inside-unit-circle? three four ) false ) ( check-expect ( inside-unit-circle? -3 -4 ) false ) This runs six tests, each of which evaluates an expression on the left (such as (inside-unit-circle? 0 0) ) and compares it to the value of the expression on the right (such as true ). If they are equal? , the test passes, but if they arent, an informative error message is displayed. Good tests exercise every branch of your code. In the example above, note that it tests a number of cases that the function might encounter: some with normal input ( 0 0 , .5 .4 , and-3, -4 ), two corner cases ( 0 -1 , and 1, 0 ), and a bad input ( three four )....
View Full Document
This note was uploaded on 07/26/2009 for the course COMPUTERSC CS51 taught by Professor Gregmorrisett during the Spring '09 term at Harvard.
- Spring '09