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

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

View Full Document Right Arrow Icon
Introduction to the Theory of Computation AZADEH FARZAN SPRING 2009 Wednesday, January 13, 2010
Background image of page 1

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

View Full DocumentRight Arrow Icon
CORRECTNESS OF SIMPLE ITERATIVE PROGRAMS Wednesday, January 13, 2010
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/11/2010 for the course CSC CSC236 taught by Professor Farzanazadeh during the Spring '10 term at University of Toronto- Toronto.

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 Right Arrow Icon
Ask a homework question - tutors are online