COMPSCI 61A Lecture Notes - Lecture 9: Abstract Data Type, Rational Number

27 views5 pages
zogo39484755 and 6 others unlocked
COMPSCI 61A Full Course Notes
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents

Document Summary

Most values are compound objects combine objects together. Abstract data type, lets us manipulate compound objects as units. Isolate two parts of a program that uses data: Data abstraction: a methodology by which functions enforce an abstraction barrier between representation and use. As soon as division occurs, the exact representation may be lost. Assume we can compose and decompose rational numbers: Rational (n, d), returns rational number x. Constructor: builds new value, instance of abstract data type. Return numer(x) * denom(y) == numer(y) * denom(x) Ways we can manipulate rationals using three functions, these functions manipulate an abstract data type. Two values that are bundled together, that you can treat them together as a whole. >>> pair = [1,2] creates new list. Return [n, d] # constructs a rational number that represents n/d def numer(x): Context of rational numbers( useful for reducing to lowest terms)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents