CPSC 225 Intermediate Programming Spring 2007

CPSC 225 Course Information

This course continues the study of programming begun in CPSC 124. We switch to C++, a language widely used by professional programmers. C++ is similar to Java in many ways, but is a more complex language and offers many low-level features (such as direct manipulation of the computer's memory) that Java does not. C++ also removes some of the automatic checks and "safety belts" that Java provides.

The goal of this course is to build on your skills as a programmer, by reviewing and extending object-oriented programming concepts from CPSC 124 (including classes, inheritance, and polymorphism) and by adding new language features (including pointers, reference parameters, operator overloading, and templates), new algorithmic techniques (recursion), and new data structures (including linked lists, stacks, queues, trees, and, time permitting, the Standard Template Library). Continued attention will also be given to "how to think like a programmer" - that is, the fundamental logical thinking and problem-solving skills which are independent of the particular language being used.


Stina Bridgeman
Lansing 312, x3614

Office Hours

M 12:30-1:30pm, W 3-4:30pm, R 10:30am-noon, F 10:30-11:30am
or by appointment (schedule)

Class Hours and Meeting Place

Lecture MWF 9:05-10am, Stern Hall 204
Lab R 8:45-10:10am, Gulick 208

Course Web Page

You are expected to regularly consult the course web page for announcements, assignments, and most handouts.


Absolute C++, 2nd edition
Walter Savitch
Addison-Wesley, 2006

Additional material will be handed out or posted on the course webpage.


C- in CPSC 124, or instructor permission


Computer science revolves around programs - creating programs, analyzing programs, making programs more efficient and easier to understand, making it easier to create and maintain programs, considering what programs can and cannot do...the list goes on. The first semester of programming is intended to introduce basic programming skills - the syntax and semantics of a particular programming language, and some of the basics of program design. The second semester of programming is intended to build a more sophisticated and confident programmer, by introducing more complex language features and placing more emphasis on program design, program organization, reusable code, and other features of the object-oriented programming paradigm. Attention will also be paid to several new data structures, to augment the arrays covered in CPSC 124. Programs are all about manipulating data, and choosing an appropriate data structure for a particular application is important for the program's efficiency and simplicity.

Course Content Overview

The course material can be divided into five major sections: program design, data structures and abstract data types (ADTs), algorithmic techniques, testing and debugging, and C++. It is worth noting that all but the last of these sections are not specific to any one programming language - while we will study them specifically in the context of C++, the ideas and strategies can easily be applied to many other programming languages.

The objectives listed below paint - in broad strokes - what the successful student should be able to do at the end of each section. The objectives marked [C++] focus specifically on the syntax and semantics of C++. For these objectives, you should be able to correctly use the thing described (both correct syntax and knowing when it is appropriate to use it) and should understand its meaning and how it is executed by the computer (the semantics).

Program Design: The single most crucial component of this course is gaining skill and confidence with program design. "Program design" refers to the process of going from an idea of what you want the program to do to a detailed enough description that the actual coding of the program is relatively straightforward. We'll study a "design recipe" (based on the design recipes of Felleisen, Proulx, Cartwright, and others) for approaching the design process, and study how to tackle the process of developing an algorithm to solve a problem.


  • be able to apply the design recipe to create a reasonable design for a program (organizing the code into appropriate classes and functions), implement that design, and defend the decisions made
  • understand the importance of the elements in the design recipe - that is, why it is a worthwhile approach
  • understand the paradigm of object-oriented programming, including the importance and use of OOP features such as inheritance, polymorphism, and abstract classes
  • [C++] basic program structure, variables, constants, expressions, statements, conditionals, loops, functions, etc
  • [C++] I/O
  • [C++] value, reference, and const reference parameters
  • [C++] automatic arrays
  • [C++] classes
  • [C++] inheritance, virtual methods, abstract classes, pure virtual methods
  • [C++] compile a program consisting of many files, from the commandline and using a makefile

Data Structures and Abstract Data Types (ADTs): Programs are, ultimately, all about manipulating data. How that data is stored and accessed can have a significant effect on how quickly a program runs, and how easy it is to write and understand a program. Topics include low-level data structures (arrays and linked lists), high-level abstract data types (vectors, lists, stacks, queues, and binary trees), and, time permitting, the C++ Standard Template Library (STL).


  • [C++] pointers, dynamically-allocated memory
  • [C++] dynamically-allocated arrays (including growable/shrinkable arrays)
  • [C++] linked structures, including linked lists and binary trees
  • be able to describe the tradeoffs in efficiency and memory usage for arrays and linked lists (all variations), and to choose the most appropriate for a given application
  • be able to correctly implement the basic algorithms involving arrays, linked lists, and binary trees (e.g. traversal, insertion, removal, destruction) and to work out algorithms for new tasks
  • be able to describe and implement the typical operations for vectors, lists, stacks, queues, and binary trees given a particular implementation
  • understand the ideas of abstraction and generic programming and why it is important to create reusable code
  • be able to explain what an abstract data type is
  • be able to choose an appropriate ADT for a given application
  • [C++] well-behaved classes which use dynamically-allocated memory
  • [C++] class templates (using existing ones only)
  • [C++] overloaded operators
  • [C++] friend functions and classes
  • (time permitting) know the properties and typical operations of the ADTs iterator, container, list, vector, deque, stack, queue, priority queue, set, map
  • [C++] (time permitting) STL implementations of iterator, container, list, vector, deque, stack, queue, priority queue, set, map

Algorithmic Techniques: One of the most useful realizations in programming is that the same kinds of problems arise over and over. Solving new problems becomes easier as you build up a toolbox of solution "patterns" - if you can match characteristics of your current problem to one that you already know how to solve, you may be able to use the known solution as a starting point for the current problem. A thorough study of algorithmic patterns is beyond the scope of this course (take CPSC 327!), but we'll be alert to solution patterns as we come across them and will study recursive search and backtracking - a very powerful technique applicable to a surprisingly large collection of interesting problems.


  • understand the idea of solution patterns, and recognize common patterns
  • understand the concept of recursion
  • implement recursive definitions
  • design and implement solutions to problems using recursive search

Testing, Debugging, and Robustness: Writing a program is only half the job - a program must also be thoroughly tested in order to verify that it works correctly. If a test fails, then the error must be located and corrected. Topics include designing robust programs (i.e. error-checking), error-prevention (or at least early detection) strategies, designing comprehensive tests, and debugging strategies.


  • be in the habit of writing pre- and postconditions for every function/method, and properly commenting your code
  • be in the habit of including error-detection mechanisms in your code
  • [C++] assertions
  • be able to create a test suite to thoroughly test a program
  • be able to systematically track down the location and cause of a bug in most circumstances
  • [C++] know the meaning of and be able to fix common compiler and linker error messages, and be able to at least guess the meaning and cause of the majority of messages encountered

C++: Along the way, we'll also study the syntax and semantics of C++. Many of the basic programming structures will be the same as Java; we'll focus on those aspects which are different or which Java does not provide. A major topic will be memory management - Java handles all of the memory allocation and deallocation automatically, while C++ gives the programmer more control. Many of the topics to be addressed are included in the objectives above; only ones not already listed are given below.


  • [C++] working with files
  • [C++] random numbers, familiarity with the math library
  • [C++] familiarity with common string-manipulation routines
  • [C++] familiarity with reading single characters, whole strings, and entire lines of text
  • [C++] C-strings, when they are used, and how they are different from C++ strings

Assignments and Evaluation

Labs: Many lab meetings will have a lab exercise. These exercises will reinforce specific concepts from class, and will generally be completed in pairs. It is intended that most lab exercises will be completed and handed in during the lab period, but solutions may be handed in any time up until the start of the following week's lab without penalty. Only one handin per pair is required.

Programming Assignments: The main focus of the course will be a series of programming assignments in which both design and implementation will be emphasized. In these, you'll go all the way from specifications to an implemented - and debugged - program. These assignments will be of different sizes, from smaller one-week programs to larger three- or four-week projects.

Journal: A regular journal is required. Becoming a good programmer is about more than just achieving the goal of a working program; you will gain more if you also reflect on the process of how you created that program. The purpose of the journal is to encourage that reflection. See the course wiki for more information and to post your journal entries.

Exams: There will be two midterm exams and a final exam. The midterm exams will each have two components - the closed-book in-class part will focus on C++ syntax and basic concepts, while the open-book take-home part will emphasize design and deeper concepts. The take-home parts may involve programming on the computer. The final exam will be closed book and will take place in the scheduled final exam timeslot. More details about each exam will be announced prior to the exam.

Final Grades: Final grades in this course will be computed as follows:

  • Labs: 20% (approx. 1.5-2% each)
  • Programming Assignments: 40% (individual assignments will be worth approx. 3-12% each)
  • Journal: 10%
  • Midterm Exams: 20% total (10% each)
  • Final Exam: 10%

Course Wiki: In addition to being where you'll post your journal entries, the course wiki is a place for comments and discussion - post questions or thoughts about the reading or lectures. Participating in the wiki is part of participating in the course; you should aim to make at least one substantive comment per week.

Attendance and Participation: You are expected to attend and participate in class and lab. The course material is cumulative and many topics will be covered, making it difficult to catch up if you fall behind. Missing class - for any reason - often results in lower grades because important material was missed. Similarly, not participating in class even if you are physically present may mean that you aren't actively following the material and thus may be missing more sophisticated or subtle points.
Attendance will be taken regularly and more than three absences (for any reason, in class or lab) will lower your final grade by 0.5% per additional absence, up to half a letter grade. No distinction is made between excused and unexcused absences when computing the final grade; however, the number of unexcused absences is considered when considering borderline final grades. See the course policies for the definition of unexcused and excused absences.

Late Policy and Collaboration: See the course policies for the late policy and collaboration policy.

Valid HTML 4.01!