am_lect_20 - Inductively Defined Sets We can define sets

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

View Full Document Right Arrow Icon
Inductively Defined Sets We can define sets inductively/recursively as well. Example 1: The set S is defined as 0 S n S , n + 1 S Note that S = N (the set of natural numbers) Example 2: The set T is defined as (0, 3) T ( w , x ) T , ( y , z ) T , ( w + y , x + z) T ( w , x ) T , ( y , z ) T , ( w y , x z) T Note that T = { (0, 3 m ) m Z }
Background image of page 1

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

View Full DocumentRight Arrow Icon
Comparing two functions Which of these two procedures is faster? 1: procedure NAE1(a : array of n reals) : bool 2: for i := 1 to n-1 3: for j := i+1 to n 4: if a[i] a[j] 5: return true 6: return false 1: procedure NAE2(a : array of n reals) : bool 2: for i := 1 to n-1 3: if a[i] a[i+1] 4: return true 5: return false Convince yourself that both procedures do the same thing. Suppose NAE1 takes T 1 ( n ) steps and NAE2 takes T 2 ( n ) steps on an array of size n It is clear that n N , T 1 ( n ) T 2 ( n ), so NAE1 is “faster”. We will
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/24/2010 for the course CS CS 173 taught by Professor Fleck during the Spring '10 term at University of Illinois, Urbana Champaign.

Page1 / 3

am_lect_20 - Inductively Defined Sets We can define sets

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online