{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

correctness-iterative

# correctness-iterative - Introduction to the Theory of...

This preview shows pages 1–6. Sign up to view the full content.

Introduction to the Theory of Computation AZADEH FARZAN SPRING 2009 Wednesday, January 13, 2010

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CORRECTNESS OF SIMPLE ITERATIVE PROGRAMS Wednesday, January 13, 2010
BASIC DEFINITIONS Program Correctness: correct output on all acceptable inputs. Te sting? Some sort of proof method? Iterative Programs: program with loops. tricky to prove correct! Induction! Wednesday, January 13, 2010

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
PROGRAM SPECIFICATION How do we specify what are acceptable inputs, and what are correct outputs? Using preconditions and postconditions ! Precondition : anything that must be before the program starts . Postcondition : anything that must be true after the program ends . including: acceptable inputs for the program. including: correct outputs of the program. Wednesday, January 13, 2010
A program which takes an array A and an element x as input, and returns the index of a cell in A that contains x ,o r 0 if no such cell exists. Postcondition. Return an integer i such that 1 i length ( A ) and A [ i ]= x , if such an integer exists; otherwise return 0.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 19

correctness-iterative - Introduction to the Theory of...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online