CSC 161 Grinnell College Spring, 2015
Imperative Problem Solving and Data Structures

Outline for CSC 161 Modules

Although this page has strong historical roots, numerous revisions and refinements are underway to reflect the evolution of this course.


The table below provides a general overview of the modules for CSC 161. Each module has these elements:

  1. an overall goal: at the end, students will have accomplished this goal
  2. a listing of topics from C, the Scribbler 2, or other areas
  3. a listing of readings (either from a textbook or from prepared materials) that provide the needed background for the topics
  4. 2-4 examples that illustrate the topics (full programs that together cover the listing of topics and could be used to introduce the material to CSC 161 students
  5. 2-4 lab exercises that engage students with the main elements needed to achieve the overall goal
  6. the description of a project that gives students practice in the topics, encourages students to integrate the ideas, and concludes with student-produced project code that does something interesting in meeting the overall goal of the module


The table references these materials:

Table Outlining Current Modules

Module Overall Purpose Summary and Main Topics Readings Illustrative Examples Lab Exercises Project Description
000 Introduction: Play a song
Introduce foundational concepts of C programming, the Scribbler robot, and the Linux terminal window. These topics comprise major components of imperative problem solving with C.
An introduction to Linux basics, C programming, and the Scribbler robots, including:
  • basic Linux
  • introduction to using the terminal
  • elements of a C program, including variables and primitive types
  • use of the eSpeak speech synthesizer
  • basic Scribbler actions (beeping)
  • reading about Linux
  • Kernighan & Ritchie: pp.1-13 (Introduction & 1.1-1.2, 2.1-2.3)
  • Scribbler 2 Notes:
    • S2 Robot Start-Up Guide
    • IPRE Reference Manual
    • generating sounds
    • eSpeakPackage.h
    • MyroC.h
  • Notes on editing, compiling, and running C code with the Scribbler 2
  • Pirates of the Caribbean
  • Spirit Song
  • Scribbler eSpeak
  • Beep and move
  • Avoid objects
  • Set robot's name
  • Linux basics
  • Overview of C
  • The eSpeak package and Linux
  • using the Scribbler 2: connect, disconnect, sound
Program a song
Develop, compile, and run a program that includes a song/melody at least 30 seconds long.
001 Motion and sensors
Introduce and explore capabilities from loops and conditionals, which are fundamental control structures of imperative problem solving. Changes of state provide contrast with functional problem solving.
An introduction to control flow in C and Scribbler programming, including
  • types and variables
  • using conditional statements (e.g., if, switch)
  • using loops (e.g., initialization, iteration, condition testing, loop body, for, while)
  • Scribbler motion
  • Kernighan & Ritchie: Sections 1.3, 2.10-2.12, 3.2-3.6 (variables, conditionals, loops)
  • Boolean values and expressions
  • Scribbler 2 sensors
  • Scribbler 2 motion
  • Dance
  • Ice cream truck
  • Couple simulation
  • Act, based on sensors
  • Loops to create patters
  • Robot navigation
  • types and variables
  • conditionals and Scribbler 2 sensors and motion
  • loop and Scribbler 2 motion,
Make the robot dance and sing.
Implement a program that controls a robot's movements to avoid obstacles. The program should include if and switch statements, for and while statements.
010 Motion and sensors
Organize data and structure algorithms to help manage the logical complexity of programs in C. Data structures include 1-dimensional arrays. Tackle logical complexity by organizing components of solutions to problems and encapsulate common tasks. Parameters include values, addresses, arrays, and function prototypes.
An introduction to the use of data structures, functions, and procedures to manage the complexity of programs. Main topics include
  • one-dimensional arrays, values and addresses as parameters,
  • testing programs and functions,
  • Scribbler 2 motion and sensors
  • Kernighan & Ritchie: Sections 1.6, 1.7, chapter 4, 5.1 (1-dimensional arrays, testing, functions, values and addresses, with the & operator)
  • Notes on arrays
  • Array parameters
  • function prototypes as parameters
  • Computing maxima, minima, and averages
  • Organizing movement data
  • Finding perimeter, area, of module
  • Programs with both values and addresses as parameters
  • Simulating throwing of darts to compute Pi
  • functions with and without value parameters, return values
  • functions with value and address parameters (2 labs)
  • 1-dimensional arrays
  • function parameters, testing
Follow a moving object
Implement an "Uninterpretable dance" in a program, in which each of several dance steps are performed in separate functions. Function parameters should include both values and addresses.
011 Utilize character data and process user input
Introduce C's model for characters and string data; allow users to enter data from the terminal, and provide mechanisms to process user data.
A consideration of ways to expand problems and problem solving from simple static programs declaration towards coded solutions that take input and follow commands based on input, including:
  • characters
  • strings
  • input/output
  • Kernighan & Ritchie: Sections 1.5, 1.9, 5.2-6, 5.10, chapter 7 (characters, strings, I/O, pointers (part 1))
  • Notes on reading data
  • Strings and characters in c
  • string storage
  • examples with scanf
  • examples with getchar and putchar
  • characters and strings
  • reading with scanf
  • character-by-character input
Robot follows typed commands (2-3 days)
Design a program that controls the robot through commands typed into the terminal. Commands include basic motion (forwards/backwards, turning, stopping), sound, and basic sensor use.
100 Image Processing
Explore additional mechanisms to group data into logical packages, and apply the general concepts to the storage, retrieval, processing, and display of images.
Data structures supporting collections
The study of general mechanisms to group data together into logical units, including
  • structs
  • 2-dimensional arrays
Discussion of common algorithms on collections, including
  • processing data in tables
  • the insertion sort
  • Kernighan and Ritchie: Chapter 6
  • structs
  • insertion sort
  • collection movement data together
  • 2-dimensional arrays
  • structs to store image data
  • insertion sort with images
  • structs
  • 2-dimensional arrays
  • transforming an image
  • insertion sort
Image processing
Develop several functions to transform images in several ways.
101 Music Composition
An introduction to dynamic storage, providing flexibility in meeting variable needs of a problem. A linked list provides a particularly flexible structure for creating and editing elements of music.
Dynamic data structures
An introduction to flexible data structures, including
  • pointers
  • memory allocation
  • linked lists
  • Kernighan and Ritchie: Chapters 5-6 structs, pointers, linked lists
  • Linked lists
  • Program management
  • Makefiles
  • malloc example
  • scheme-like lists
  • general lists
  • lists for movies
  • pointers
  • Scheme-like lists
  • Linked lists in C
  • Linked lists for a movie
  • Program management, header files
Music composition --- insertion of series of notes periodically into song tune (2-3 days)
Develop/expand a program to store and edit notes in a song, Basel on the flexibility of a dynamic linked list structure.
110 Stacks and Queues as Fundamental Abstract Data Types
An exploration of two fundamental abstract data structures: stacks and queues, together with implementations using both arrays and linked lists.
A study stacks and queues as abstract data types, together with several possible implementations, including
  • arrays storing references to original data
  • arrays storing copies of data
  • linked lists, based on Scheme-like lists
  • general linked lists
  • Reading on stacks
  • Reading on queues
  • Reading on bash scripts
  • Variations on stack implementations
  • stacks
  • queues (with arrays)
  • queues (with linked lists)
  • bash scripts
Study consequences of different stack implementations
Given 4 different stack implementations, consider what is stored, what is returned, and consequences of each approach
7 Integrated Robotics
A review of common approaches to integrate a wide range of problem-solving techniques and programming concepts in C in the control of Scribbler 2 robots.
Advanced Input/Output
Many elements throughout the course can be brought together in the control of robots, including
  • Command-line arguments
  • File streams
  • Text files (organized by line)
  • Kernighan & Ritchie: Sections 5.10, Chapter 22 (files, command-line arguments, sorting, queues)
  • Working with Strings
  • generating files
  • reading files as streams
  • reading files line-by-line
  • reading state data by year
  • command-line arguments
  • reading file streams
  • reading text files
Controlling a robot, with command logging
integrate sensors, motion, song; loops, conditionals, i/o, functions, files, and command-line arguments in a common setting