# CMPU-101-54 Computer Science I and Lab. (Spring 2019)

## Labs

### Problems and Solutions

Week | Lab. | Problems | Sample Solutions |
---|---|---|---|

1 | 0 | Lab. 00 Problems | |

2 | 1 | Lab. 01 Problems | Solutions to Lab. 01 |

3 | 2 | Lab. 02 Problems | Solutions to Lab. 02 |

4 | 3 | Lab. 03 Problems | Solutions to Lab. 03 |

5 | 4 | Lab. 04 Problems | Solutions to Lab. 04 |

6 | 5 | Lab. 05 Problems | Solutions to Lab. 05 |

8 | 6 | Lab. 06 Problems | Solutions to Lab. 06 |

9 | 7 | Lab. 07 Problems | Solutions to Lab. 07 |

10 | 8 | Lab. 08 Problems | Solutions to Lab. 08 |

11 | 9 | Lab. 09 Problems | Solutions to Lab. 09 |

12 | 10 | Lab. 10 Problems | Solutions to Lab. 10 |

13 | 11 | Lab. 11 Problems (Bonus Lab) |

### Lab. Descriptions

#### Lab. 00

*Friday, 25th January, 2019*

This lab. is intended to help you set up your Vassar CS department Linux account, get used to using DrRacket (the program we use to work in Scheme), and to let you try out saving some work to disc and then loading it back into the computer and running it again.

#### Lab. 01

*Friday, 1st February, 2019*

In this lab. you will be getting lots of practice using the `printf`

statements, as well as using `define`

to create functions. You will also get your first chance to submit your work using the `submit101`

command.

#### Lab. 02

*Friday, 8th February, 2019*

This lab explores using `IF`

and `COND`

to make decisions. You will also use a new built-in function, `RANDOM`

, which lets the computer pick a random number. You will also begin to use the `asmt-helper.txt`

file, if you haven't already done so.

#### Lab. 03

*Friday, 15th February, 2019*

This lab. is all about recursion and writing functions that call themselves to perform a task. This is an important and integral part of Scheme, and of computer science in general. There are also some problems involving the conditionals `if`

and `cond`

.

#### Lab. 04

*Friday, 22nd February, 2019*

We have been looking at several different subjects of late:

- recursion;
- conditional expressions using
`if`

and`cond`

; - the boolean operators
`AND`

,`OR`

and`NOT`

; - writing predicate functions, with or without conditionals.

This lab. is intended to give you some practice with writing predicate functions and using boolean operators.

#### Lab. 05

*Friday, 1st March, 2019*

Manipulating non-empty lists is one of the most common operations in Scheme. We have seen how we can use the list operators `first`

, `rest`

and `cons`

to access parts of a list and to stitch lists back together – or maybe even create new ones.

This lab. is intended to give you some practice using lists and list-based recursion, and to support you in solving the problems in this week's assignment.

#### Lab. 06

*Friday, 29th March, 2019*

This lab. will give you some more practice with list recursion. You will also practice re-writing non-tail-recursive functions as tail-recursive functions, as well as working with accumulators.

#### Lab. 07

*Friday, 5th April, 2019*

For the past couple of weeks we have been playing with accumulators, wrapper functions and list recursion. This lab. is intended to wrap up the topic with a few final problems, including working through hierarchical lists – i.e. lists which contain lists. There is even a bonus question…

#### Lab. 08

*Friday, 12th April, 2019*

This week we have been working on local environments and variables, using `let`

, `let*`

and `letrec`

. This lab. gives you the chance to practice with these expressions, in part by revisiting problems you have already seen and rewriting them.

#### Lab. 09

*Friday, 19th April, 2019*

There have been many changes lately. Moving to using `let`

and `let*`

to handle variables, and writing self-contained recursive functions with `letrec`

. Now we can use **iteration** to solve problems, with the loop control functions `while`

and `dotimes`

, though we need to `set!`

our own variables now. Ah, the vicissitudes of destructive programming…

#### Lab. 10

We have reached the end of this exploration of ideas of computer science, with two new ways of storing information: the **vector** and the concept of the **data structure**. In this lab. we will revisit a couple of old problems to see how we can recreate them using vectors, and then explore the connections between data structures, Scheme, and poker…

#### Lab. 11 (Bonus Lab.)

There are many interesting computations which can be done in mathematics. Some we have seen in class: the Fibonacci series and the Ackermann function, for example, but there are many more. Computers can help us with the vast majority of them. One of my favourites is the idea of the 'happy number': a number is happy if… Well, read the lab. instructions and find out what makes a number happy – or not.

This lab. is 100% optional. It is worth 3 bonus lab. points.