The following table indicates assignments and due dates for Computer Science 195. Unless otherwise indicated, textbook references are to course textbooks. Additional exercises are stated later on this page. Rules for submitting programs are given at the bottom of this page.
Collaboration is allowed on some assignments and not on others; specific rules of collaboration are shown for each assignment.
| Due Date | Text | Chapter | Collaboration | Problems |
|---|---|---|---|---|
| September 5 | Gries | 1 | No | 1.3, 1.4 |
| September 10 | C Prog. | 1, 2 | No | Lab 1: Elementary C Programming |
| September 11 | Gries | 2 | No | 2.5, 2.6cefghjkl |
| September 17 | C Prog. | 1, 2 | Yes | Lab 2: Representation of Integers |
| September 25 | Gries | 4 | No | 4.1.3, 4.2.6a-bjkm, 4.4.2, 4.5.2ac |
| Gries | 5 | No | 5.1.1ace, 5.1.2bfg, 5.2.2, 5.2.3 | |
| September 26 | C Prog. | 1, 2 | No | Lab 3: Floating Point Numbers |
| October 2 | C Prog. | 1, 2 | No | Lab 4: Functions and Parameter Passage |
| October 9 | Gries | 6 | No | 6.2.1deg |
| October 17 | Gries | 7 | No | 7.1acef, 7.2(1,3,5), 7.4, 7.5 |
| Gries | 8 | No | 8.1, 8.3, 8.6 | |
| November 7 | Gries | 9 | No | 9.1.1ace, 9.2.2, 9.2.3bdf, 9.2.4ace, 9.3.1ace |
| November 12 | Gries | 10 | No | 10.1, 10.3, 10.5, 10.6, 10.8 |
| November 19 | Gries | 11 | No | 11.1, 11.8, 11.9, 11.10, 11.12 |
| November 26 | Gries | 14 | No | 14.1abd |
| November 28 | C Prog. | No | Problem 1 | |
| December 3 | Gries | 15 | No | 15.1.3, 15.1.4, 15.2.2 |
| December 7 | Gries | 16 | No | 16.2.2, 16.2.3 |
| December 10 | Gries | 16 | No | 16.3.1, 16.3.5, 16.3.7 |
| December 14 | Gries | 16 | No | 16.5.2, 16.5.5, 16.5.9 |
| Due Date | Text | Chapter | Collaboration | Problems |
Problem 1: Binary Search
Given integers k and n, with k < n-1, and C array a[n] of integers, and integer item. Suppose array segment a[0]..a[k] is sorted in ascending order.
Write a C-function:
int search (int * a, int k, int item)
that performs a binary search of array segment a[0]..a[k] and
returns variable i satisfying the following post-condition:
(0 < i < k+1 < n) AND
((item = a[i]) OR ((ForAll j: 0 < j < i: a[j] < item)
AND (ForAll j: i < j < k: a[j] > item)))
That is, function search performs a binary search and returns
variable i where either:
Note: Your function should be iterative (not recursive), and it should be constructed so that the only return statement is at the very end and has the form return i;
Submitting Programs For This Course: In turning in any programs for the course, please follow these directions:
/**************************************
* Henry M. Walker *
* Box Science II *
* Program for CSC 195 *
* Assignment for Friday, September 1 *
**************************************/
Also, a comment is needed for every definition of a C function, stating
both pre- and post-conditions for that program unit.
if ((no_comments)
|| (missing pre- or post-conditions)
|| (no_evidence_of_compilation)
|| (no_test_runs)
|| (no_commentary_on_correctness))
return (no_grade);
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~walker/courses/195.fa01/assignments.html
|
created August 26, 2001 last revised November 20, 2001 |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |