DOC PREVIEW
Berkeley COMPSCI 61A - Lecture 8

This preview shows page 1-2-3-4-5-6-7-51-52-53-54-55-56-57-58-102-103-104-105-106-107-108 out of 108 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

61A Lecture 8Wednesday, September 14Sunday, September 11, 2011Data Abstraction2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude•An abstract data type lets us manipulate compound objects as units2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude•An abstract data type lets us manipulate compound objects as units•Isolate two parts of any program that uses data:2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude•An abstract data type lets us manipulate compound objects as units•Isolate two parts of any program that uses data:How data are represented (as parts)2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude•An abstract data type lets us manipulate compound objects as units•Isolate two parts of any program that uses data:How data are represented (as parts)How data are manipulated (as units)2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude•An abstract data type lets us manipulate compound objects as units•Isolate two parts of any program that uses data:How data are represented (as parts)How data are manipulated (as units)•Data abstraction: A methodology by which functions enforce an abstraction barrier between representation and use2Sunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude•An abstract data type lets us manipulate compound objects as units•Isolate two parts of any program that uses data:How data are represented (as parts)How data are manipulated (as units)•Data abstraction: A methodology by which functions enforce an abstraction barrier between representation and use2All ProgrammersSunday, September 11, 2011Data Abstraction•Compound objects combine primitive objects together•A date: a year, a month, and a day•A geographic position: latitude and longitude•An abstract data type lets us manipulate compound objects as units•Isolate two parts of any program that uses data:How data are represented (as parts)How data are manipulated (as units)•Data abstraction: A methodology by which functions enforce an abstraction barrier between representation and use2All ProgrammersGreat ProgrammersSunday, September 11, 2011Rational Numbers3Sunday, September 11, 2011Rational Numbers3numeratordenominatorSunday, September 11, 2011Rational NumbersExact representation of fractions3numeratordenominatorSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integers3numeratordenominatorSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integersAs soon as division occurs, the exact representation is lost!3numeratordenominatorSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integersAs soon as division occurs, the exact representation is lost!Assume we can compose and decompose rational numbers:3numeratordenominatorSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integersAs soon as division occurs, the exact representation is lost!Assume we can compose and decompose rational numbers:3numeratordenominator•make_rat(n, d) returns a rational number xSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integersAs soon as division occurs, the exact representation is lost!Assume we can compose and decompose rational numbers:3numeratordenominator•make_rat(n, d) returns a rational number xConstructorSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integersAs soon as division occurs, the exact representation is lost!Assume we can compose and decompose rational numbers:3numeratordenominator•make_rat(n, d) returns a rational number x•numer(x) returns the numerator of xConstructorSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integersAs soon as division occurs, the exact representation is lost!Assume we can compose and decompose rational numbers:3numeratordenominator•make_rat(n, d) returns a rational number x•numer(x) returns the numerator of x•denom(x) returns the denominator of xConstructorSunday, September 11, 2011Rational NumbersExact representation of fractionsA pair of integersAs soon as division occurs, the exact representation is lost!Assume we can compose and decompose rational numbers:3numeratordenominator•make_rat(n, d) returns a rational number x•numer(x) returns the numerator of x•denom(x) returns the denominator of xConstructorSelectorsSunday, September 11, 2011Rational Number Arithmetic4Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*910=Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*910=nxdxnydy*Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*910=nxdxnydy*nx*nydx*dy=Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*910=3235+nxdxnydy*nx*nydx*dy=Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*910=3235+2110=nxdxnydy*nx*nydx*dy=Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*910=3235+2110=nxdxnydy*nx*nydx*dy=nxdxnydy+Example:General Form:Sunday, September 11, 2011Rational Number Arithmetic43235*910=3235+2110=nxdxnydy*nx*nydx*dy=nxdxnydy+nx*dy


View Full Document

Berkeley COMPSCI 61A - Lecture 8

Documents in this Course
Lecture 1

Lecture 1

68 pages

Midterm

Midterm

5 pages

Midterm

Midterm

6 pages

Lecture 35

Lecture 35

250 pages

Lecture 14

Lecture 14

125 pages

Lecture 2

Lecture 2

159 pages

Lecture 6

Lecture 6

113 pages

Lecture 3

Lecture 3

162 pages

Homework

Homework

25 pages

Lecture 13

Lecture 13

117 pages

Lecture 29

Lecture 29

104 pages

Lecture 11

Lecture 11

173 pages

Lecture 7

Lecture 7

104 pages

Midterm

Midterm

6 pages

Midterm

Midterm

6 pages

Lab 4

Lab 4

4 pages

Lecture 7

Lecture 7

52 pages

Lecture 20

Lecture 20

129 pages

Lecture 15

Lecture 15

132 pages

Lecture 9

Lecture 9

95 pages

Lecture 30

Lecture 30

108 pages

Lecture 17

Lecture 17

106 pages

Load more
Download Lecture 8
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 8 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 8 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?