HO28A - Maggie Johnson CS103A Handout #36 Functions Key...

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

View Full Document Right Arrow Icon
Maggie Johnson Handout #36 CS103A Functions Key topics: * Introduction and Definitions * Types of Functions * The Growth of Functions As used in ordinary language, the word function indicates dependence of a varying quantity on another. If I tell you that your grade in this class is a function of the number of thousands of dollars you pay me, you interpret this to mean that I have a rule for translating a number in thousands into a letter grade. More generally, suppose two sets of objects are given: set A and set B; and suppose that with each element of A there is associated a particular element of B. These three things: the two sets and the correspondence between elements comprise a function. A function f is a mapping from a set D to a set T with the property that for each element d in D, f maps d to a unique element of T, denoted f(d). Here D is called the domain of f, and T is called the target or co-domain . We write f: D -> T. We also say that f(d) is the image of d under f, and we call the set of all images the range R of f. A mapping might fail to be a function if it is not defined at every element of the domain, or if it maps an element of the domain to two or more elements in the range: Use Word 6.0c or later to view Macintosh picture. To define a function f, we must specify its domain D and a rule for how it operates. Example 1 Let B be the set of all binary numbers, or equivalently all finite strings of 0's and 1's. Let N be the set of natural numbers expressed in decimal notation. f, g, h, j are the following functions: f(s) = decimal equivalent of s g(s) = number of bits in s h(s) = number of ones in s j(s) = ones bit of s
Background image of page 1

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

View Full DocumentRight Arrow Icon
If s = 110010 then f(s) = 50, g(s) = 6, h(s) = 3, j(s) = 0. The range of f, g, h, is
Background image of page 2
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 04/15/2008 for the course CS 103A taught by Professor Plummer,r during the Fall '07 term at Stanford.

Page1 / 4

HO28A - Maggie Johnson CS103A Handout #36 Functions Key...

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