San Jose State University : Site Name


Main Content

Working in Mars Mission Control, JPL

Ronald Mak

Department of Computer Engineering
Spring Semester 2017

Office hours: Th: 2:30-4:30 PM
Office location: ENG 250
Mission Control, Jet Propulsion Laboratory (JPL)
NASA Mars Exploration Rover Mission

CMPE/SE 180-92: Data Structures and Algorithms in C++

Instructional Student Assistants
Weekly Tutoring Schedule

Saurabh Bhatkar
Monday 3:00-5:00 PM, room E405

Savio Fernandes
Tuesday 12:00-2:00 PM, room E206
Amit Chougule
Wednesday 2:00-4:00 PM, room E405

Section 1: Th 6:00 - 8:45 PM, room ENG 189


# Assigned Due Assignment
1 Jan 26 Feb 2 Presidents
Input file:

Sample solution: presidents-draft.cpp    presidents.cpp
2 Feb 2 Sep 9 Rock Paper Scissors

Sample solution: rps.cpp
3.a Feb 9 Feb 16 Prime Numbers

Sample solution: primes.cpp
3.b Feb 9 Feb 16 Spirals

Sample solution: spirals.cpp
3.c Feb 9 Feb 16 Prime Spirals

Sample solution: PrimeSpirals.cpp
4 Feb 16 Feb 23 Big Pi

Sample solutions: BigPi.cpp    BigPiMillion.cpp
Sample output (one million digits with timings): You must compile with --std=c++11 to use the chrono timer package. BigPi-Debian.out
C++ library version: Run configure --enable-cxx to build the library extension for C++, and you must also #include <mpirxx.h>. Note that the arithmetic operators are now overloaded. BigPiCXX.cpp
5 Feb 23 Mar 2 Rational

Input file:
Sample solution: rational.cpp
6 Mar 2 Mar 9 Employee Records

Input file:
Sample solution: Employee.h    Employee.cpp    EmployeeApp.cpp
7 Mar 13 Mar 23 U.S. maps

Input files: boundary-data.csv   city-data.csv
Sample solution:


Date Content
Jan 26 Slides: Course objectives; software to install; assignments; quizzes; exams; grading; what is C++; Hello World program; Pods and Peas program; identifier, variables, and keywords; assignment statements; input and output; #include and using namespace; formatting numbers; cin input; basic data types; string type; type compatibilities and conversions; arithmetic; operator shorthand; if statement; while loops; named constants; Boolean operators; precedence rules; enumeration types; nested if statements; switch statement; increment and decrement operators; for loops; break statement

Savitch slides: 01 02 03
Example programs: helloworld.cpp   Savitch_01-08.cpp   Savitch_03-06.cpp   Savitch_03-14.cpp
Feb 2 Slides: Predefined functions; random numbers; type casting; programmer-defined functions: declarations, definitions, calls; void functions; top-down design; number translator example; scope and local variables; block scope; global constants and variables; overloading function names; call-by-value; call-by-reference; procedural abstraction; testing and debugging functions; assert macro; Assignment #2 Rock Paper Scissors

Savitch slides: 04 05
Top-down design example:
int2words-1.cpp   int2words-2.cpp   int2words-3.cpp   int2words-4.cpp   int2words-5.cpp
Pass-by-value example: swap.cpp
Pass-by-reference example: exchange.cpp
Feb 9 Slides: Assignment #2 sample solution; streams; file I/O; stream name vs. file name; formatting output; output manipulators; passing streams to functions; character I/O; predefined character functions; eof function; arrays; array initialization; array function parameters; Assignment #3.a Prime Numbers; multidimensional arrays; Assignment #3.b. Spirals; C strings; the standard string class; vectors; Assignment #3.c. Prime Spirals

Savitch slides: 06 07 08
Feb 16 Slides: Assignment #3 solutions; sample solutions; pointers; int vs. pointer to int; declaring and assigning pointers; pointers are addresses; address-of and dereferencing operators; new and delete operators; pointer parameters; typedef; using pointers to pass-by-reference; pointers and arrays; pointer arithmetic; dynamic arrays; char* and char**; Assignment #4 Big Pi

Savitch slides: 09
Dynamic array example: DynamicArray.cpp
Feb 23 Slides: Assignment #4 sample solutions; structures; structures are types; scope of member names; structure variables; object-oriented programming (OOP); classes; member functions; public and private members; constructors; abstract data types (ADT); friend functions; operator overloading; overload <<; overload >>; Assignment #5 Rationals

Savitch slides: 10
Example class Birthday v1: Birthday1.cpp
Example class Birthday v2: Birthday2.cpp
Mar 2 Slides: Assignment #5 sample solution; array of objects; destructors; separate compilation; vector of objects; copy constructor; namespaces; search an array: linear search and binary search; Assignment #6 Employee Records

Savitch slides: 11 12
Example class Birthday v3: Birthday.h   Birthday3.cpp   BirthdayTester3.cpp
Example class Birthday v4: Birthday.h   Birthday4.cpp   BirthdayTester4.cpp
Example class Birthday v5: Birthday.h   Birthday5.cpp   BirthdayTester5.cpp
Mar 9 Slides: Assignment #6 sample solution; a "safe" array type; assignment operator; overload the subscript operator []; copy constructor; linked list insertion and deletion; queue; stack; Assignment #7; namespaces

Savitch slides: 13
SafeArray example 1: SafeArray1.h   SafeArray2.cpp   SafeArrayTests1.cpp
SafeArray example 2 (operator =): SafeArray2.h   SafeArray2.cpp   SafeArrayTests2.cpp
SafeArray example 3 (fix operator =): SafeArray3.h   SafeArray3.cpp   SafeArrayTests3.cpp
SafeArray example 4 (overload []): SafeArray4.h   SafeArray4.cpp   SafeArrayTests4.cpp
SafeArray example 5 (copy constructor): SafeArray5.h   SafeArray5.cpp   SafeArrayTests5.cpp
Mar 16 Slides: Shorthand for pointer expressions; a sorted linked list: searching, inserting, removing; inheritance; subclasses; polymorphism; virtual destructors

Savitch slides: 15
Mar 23 Slides: Midterm solutions; Assignment #7 sample solution; exception handling; exception classes; throwing exceptions in a function; templates; Standard Template Library (STL), iterators; vector iterator; kinds of iterators; containers; list template class; linked list vs. vector; Assignment #8; chrono

Savitch slides: 16 18

Midterm solutions

Exception handling examples: exception1.cpp   exception2.cpp   exception3.cpp
Vector iterator examples: IteratorVector1.cpp   IteratorVector2.cpp
Elapsed time example: TimeVector.cpp


First goal: You will learn to design and write well-crafted programs in a useful subset of the C++ language.

Second goal: You will learn how to use C++ to implement some fundamental algorithms and data structures reliably and efficiently.

Learning to program well in a language like C++ requires much practice! You should expect to write one or more programs each week. The programming assignments will become increasing more challenging during the semester.


Admission into the CMPE or SE masters program.

Required books

Problem Solving with C++, 9th edition
Walter Savitch
Pearson, 2015
ISBN: 978-0133591743
Data Structures Using C++, 2nd edition
D.S. Malik
Cengage Learning, 2010
ISBN: 978-0324782011

Software to install

For the Mac, Linux, or Windows platform, install one of the following integrated development environments (IDE) for C++ development:

GNU C++ is usually pre-installed on the Mac and Linux platforms. On Windows, you must first download and install the GNU C++ compiler via Cygwin.

You can also use Apple's Xcode on the Mac, or Microsoft Visual C++ on Windows. But then you run the risk of writing programs that will not port to other platforms.

On Windows, you must first download and install GNU C++ via Cygwin. See:

Despite what the second video shows, do not use Notepad to edit your programs on Windows! Download and install Eclipse or NetBeans and use the IDE to edit, compile, and run your programs.

Do not install MinGW instead of Cygwin. MinGW in a minimum C++ installation that lacks many of the POSIX libraries required by some of the assignments.