CS 1321 (Principles of Algorithm Design II):
Sample Programs
Programs from class
- (January 14) Program to echo command-line arguments, one per line.
- (January 14) sum.cc: Program to sum numeric command-line
arguments and print result.
- Section 3 version, typed by M. Cheng:
sum.cc.
- Section 4 version, typed by S. Winston:
sum.cc.
- (January 17) Simple "clock" class and test program.
- (January 19) An implementation of a list ADT.
- (January 21) Simple 3D vector class, plus test program.
- (January 24) More versions of 3D vector class.
- Integer version, modified to demonstrate use of
functions as parameters
int_vector_v2.cc.
- Integer version, further modified to include
"dot product" function
int_vector_v3.cc.
- (January 26) stl_vector_example.cc: Program to demonstrate
simple use of STL "vector" class.
- (February 9, 11) Shopping-cart class, take 1. (Courtesy of
J. Oldham.)
- (February 21) Shopping-cart class, take 2. (Courtesy of
J. Oldham.)
- (February 28) Examples showing use of dynamic-memory
allocation. All programs read in a sequence of
numbers and then print them out in two-column format.
- (March 20) Doubly-linked list class and example of use.
- List class definition:
dll.h.
- Buffer class definition, using list class:
buffer.h.
- String editor, using buffer class:
editor.cc.
- (March 31) Double-ended queue and test program.
- Double-ended queue class:
deque.h.
(Numbers in comments indicate how this
class could be implemented in several
stages.)
- Test program for double-ended queue class:
deque.cc.
- (April 3) Doubly-linked list class, revised to use iterator.
- Revised list class definition:
dll.h.
- Revised buffer class definition, using list class:
buffer.h.
- String editor, using buffer class:
editor.cc.
- (April 7) Tree template class.
- (April 10) Binary search trees.
- Binary search tree functions:
bst.h.
Note that this is not a separate class, but a
collection of functions that operate on trees
as defined in our tree class
tree.h.
- Example of using BST functions:
bst.cc.