COMPSCI 61A Study Guide - Midterm Guide: Binary Search Algorithm, Object-Oriented Programming, Mutation Testing

104 views13 pages
10 May 2018
School
Professor
Notes
.
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 13 pages and 3 million more documents.

Already have an account? Log in
Lecture Notes
,
Data Abstraction
Data Abstr :Data abstraction :method where functions enforce an abstraction banor between representation and use
°Compound object :eX :date
ex :constructor :rational (h
;D )#these functions implement an abstract datatype for
selector :numercx ),denom( ×)rational numbers
bstractionbamiors
1.) Use #to compute functions (add )Barrio :don't create rational with add
2.) create rational rational ,nvmehdenom
3.) Implement constructor element selection
List Pairs :[ 1,2 ]
.list literal :[ a,b] *can do :torx ,y impairs
.pair :[ 1,2]from operator import get item
x,y= pair (unpacking the list )get .tem( pair,O):element selection function
containers :-listlrangefzzd :G .
.to ,D :list constructor
.list comprehension :[ xforxintahgeco ,n)ifh%2==o]
.
slicing :nCl
:3
].
,
[:D 0,1 ,2 ,
[:] :ah
,[3 :] 3. D.add negative
i. popl ):removes andrewmslastelementappendl ):adds one .extends ''
.
''
... ]:add multiple
l=[ 'n' ,'b '].,
print l→[G ,'b']Slicing fiffaaorifc :: .1) switches
.sequence Aggregation
-sumliterable Gstart ]:sometimes needstaningtypetosmotiterabhe
-maxliterableckeuffvn D)
valve ermaxd ,?3frey= and )
.
-alliterate )boot
Strings :
exedstnng
.actually does stuff
" " "
:multiple lines .
'th :new line
Dictionary
create :{ '
key
'
=value ,... }eahthavesamekeytwice
don't have an inherent order .can't use listldictaskebs
ex :n={ 'I:L
,'ll :5 ,X'
:l0} °nCI ']→l .unordered
in .Keys( Hdict .keys( 'It ,'v :$ n.P0P( 'Key ):removes and returns value at key
.nvaweslbnitemsl )
.
'
key 'inn→ True or ngetlix .ray ',o)→0 Idefault
edict comprehension :{ x:x* xfovxinvanaelkd }.
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 13 pages and 3 million more documents.

Already have an account? Log in
Branch
.io#iITYetaabei
. node
each node has alabel
TREES ::path
sum( [[I],[ 2,3 ],[4]],[ ]) [1,2/3,4]
'
'
3,3g:tree( 3Green ,
treelzftreelb .height"@
tree DDD
deftreec label ,branches 't ]):
for bin branches :
return [label ]#
ranches assert is .tree (branch )
deflabektreej listc )
return tree !]
def branches (tree :1
return trees :]
Hdetislreeltred :
iftypekredtlistorlenctredd
return False
for bin branches .:
.
ifhotis .tree (branch ):
-
retumtalse
return True
defisteafc tree )
retumnotbrancheskred
Hpncess
defwunt .leaves #:
it is .leaf #:
retunnl
else :
counts -- (count .leaves (b) forbin branches LED
retvvnsvmlwmts
.
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 13 pages and 3 million more documents.

Already have an account? Log in
zogo39484755 and 6 others unlocked
COMPSCI 61A Full Course Notes
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents

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

Related Documents