5/4/2009
Ve 280 Manifesto Ve 280
Programming and Introductory Data Structures
Mathematics, especially as used by physics, is the formalism we use to describe what is
The physical world is modeled by equations. Solutions to these equations give us insight
5/4/2009
Abstraction Ve 280
Programming and Introductory Data Structures
Abstraction is a many-to-one mapping that reduces complexity and eliminates unnecessary details by providing only those details that matter. For example, there are several ways to im
5/6/2009
Recursion
Another kind of factorial
Ve 280
Programming and Introductory Data Structures
Tail Recursion and Intro to Testing
Re-write the recursive version to use the same amount of space as is required by the th iterative version (approximately).
5/6/2009
Five Steps in Testing Ve 280
Programming and Introductory Data Structures 1.
To test some piece of code (either a component or a whole piece): Understand the specification Identify the required behaviors 3. Write specific tests 4. Know the answer
5/10/2009
Review
General Recursion
Ve 280
Programming and Introductory Data Structures
A recursive problem is one that is defined in terms of itself. A recursive problem has two important features:
1. 2.
Recursion and Iteration
There be one or more trivia
5/10/2009
On to Arrays
Data Types weve seen so far
Ve 280
Programming and Introductory Data Structures
atoms: types with singleton values.
For example, something of type int holds one integer. Something of type char holds one character.
Arrays and Pointer
5/12/2009
Pointer Review
Working with addresses
Ve 280
Programming and Introductory Data Structures
To declare a pointer to an int, we say: int *bar; Notice the *. It means pointer-to. We can assign values to a pointer, just as we can to any other just va
5/12/2009
Pointer Arithmetic
Recall
Ve 280
Programming and Introductory Data Structures
Remember that both of the following expressions are examples of pointer arithmetic: array[3] *(array+3) Recall that an address is a location in memory. Each byte in me
5/17/2009
Announcements Ve 280
Programming and Introductory Data Structures
Project 2 files were messed up on Sakai they should now be correct
There is no tree_find() function You must implement the contained_by() function You You have one extra day to fi
5/17/2009
Exceptions
Motivation
Ve 280
Programming and Introductory Data Structures
We want a means of recognizing and handling unusual conditions in your program at runtime, not just at compile time. If you have a function that does not produce meaningfu
5/17/2009
Remembering Back
Types
Ve 280
Programming and Introductory Data Structures
Recall the role of a type:
The set of values that can be represented by items of the type The set of operations that can be performed on items of the type.
Abstract Data
5/17/2009
Abstract Data Types
Recall Using Classes
Ve 280
Programming and Introductory Data Structures
Recall our abstraction that held a mutable set of integers. This is a set in the mathematical sense:
A collection of zero or more integers, with no dupl
5/25/2009
Announcements Ve 280
Programming and Introductory Data Structures
struct Outcome cfw_ bool canMove; / true if a move exists, false if forfiet int pawnNum; / Which of the player's pawns to move Pawn oppononet;/ Which opponent is victim of swap/so
5/25/2009
Getting access to our CTools site Ve 280
Programming and Introductory Data Structures 1.
Create a Friend Account (if you dont already have umich access):
http:/www.itd.umich.edu/itcsdocs/s4316/ (follow the instructions)
2. Once your account is c
5/21/2009
Invariants
Recall: Checking for Representation Invariants
Ve 280
Programming and Introductory Data Structures
Last time, we showed how to confirm that an array was sorted, with no duplicates. Base cases:
Memory Models
An array of zero elements i