by - logan frankedxq?2mr2mb2 t ` k2i2`m k2bm k2i?q/+qmi` +i-r? ip hm2 `2r2`272``bm;iqr?2mi?2 t `...

14
I¢P ‹‹‹q _ iaN“Q¡j ‹ ¢“fiN„ YfiaNQ '¡QQ£ qw ‡^;“ a£ “^Q NQ´la“apl pV “^Q £a»Q pV ; “¡QQ{ ‹w ‡^;“ a£ “^Q NQ´la“apl pV “^Q ^QaZ^“ pV ; “¡QQ{ «w ‡^;“ a£ “^Q NQ´la“apl pV ; s;“^{ ‡^;“ a£ “^Q gQlZ“^ pV ; s;“^{ Ipl£aNQ¡ “^Q Vpggp·alZ “¡QQ Vp¡ zfiQ£“apl£ W_qqK Ww ‡^;“ a£ “^Q ¡pp“ pV “^Q “¡QQ{ ƒw ‡^;“ ;¡Q “^Q l;jQ£ pV “^Q J^agN¡Ql pV “^Q ¡pp“ lpNQ{ ¥w ]p· j;l„ J^agN¡Ql NpQ£ lpNQ ~ ^;†Q{ Rw ]p· j;l„ gQ;†Q£ ;¡Q al “^Q “¡QQ{ mw ]p· j;l„ J^agN¡Ql NpQ£ lpNQ P ^;†Q{ q…w ‡^;“ lpNQ a£ “^Q s;¡Ql“ pV :{ qqw ‡^;“ a£ “^Q £a»Q ;lN ^QaZ^“ pV “^Q “¡QQ{ kp“ Za†Ql ;£ zfiQ£“apl£L Bfi“ „pfi lQQN “p elp· ¶if'¡QQ VfilJ“apl£ £fiJ^ ;£ lfijBQ¡oVI^ag_ N¡QlL a£';ZL J^agNL g;BQgL Q“Jw q of nodes in a tree longest path from rootto leaf in a tree largest of nodes a series of nodes connected by edges where length is the of nodes each node is a parent or child of another in a path B K R S Z 7 0 K 12 4

Upload: others

Post on 16-Feb-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

  • of nodes in a tree

    longest pathfromroottoleaf in a tree largest ofnodes

    a series of nodes connected byedges where length is the of nodeseach node is a parent or child of another in a path

    B

    K R S

    Z

    7

    0

    K12 4

  • O N technically limitedby memorythough

    int has a limit while string has a much much largerlimit

    instance methods

    receiver

    this distinguishedformal parameter

    new valueof this will be equal to the oldvalveof this plusone

    yes objectvalve changes

    if you have x copyFromCyd thissaysyou will still need yat its current value later in the code

    anyvalue where X o Cie a positive number

    adding to ones place after multiplying

    zero multiplyBylo divideBy10 very essential methodsto be used in all NaturalNumber objects

    0

    0

  • objects

    reference

    actual

    memory

    2 referencevalve objectvalve

    mystr a unoclassuntilmarun3othicT

    myNN a 1455J

    455

    No wecan't doarithmetic on thememory addresses thereforetheyarearbitrary

    nm nm will have the samereference valve andtherefore will be aliases

    No a s b 5 can mean aliases or two different referencevalues with thesameobject valve and a s b 5 strictlymeans thelatter

    theobject value

  • stri doesn't change strz doeschangebc strings arebuilt directly intoJava

    whentwo variables share thesame reference value m ago huh Pionteonrtifflyn2 a ambiguousmm isa referencetypewheretheobjectvalue cannot be changed

    withoutchangingthenierencevaluethereferencetypecontainsnomethodsthatcandirectlychangetheobjectvaluewithoutweedingthereferencevalue

    a referencetypewheretheobjectvaluecanbe changedwithoutchangingthenierencevalue

    immutable

    mutable

    value

    the reference valuechanges to anewmemorystr

    temp

    is temp addess bc immutablevalue

    ma 11 nothing

    passbyvaluecopybyvalue

    passbyreferencevaluecopybyreferencevalue

    maina aa doesn't changein main

    I unaffectedw a a so

  • Str equalsstir nmcompareToCnn2 s z e someValue

    bothcompare referencevalues

    reference

    any as long as sametype

    copythereference valve

    compare referencevalues

    passbyreferencevalue

    arr a

    arr a

    11hDo 034

  • nvm 04 4 temp

    object value

    yes no

    restores var

  • clears var

    replaces varensures var 5

    updates varensures var var15

    restores

    no relationship

    THE valve objectvalue

    no this arg

    nnl nh2j

    technically yes if youdo NaturalNumber n this

    yes yes

  • c s E 2 2 2 l 7 string ofcharacters

    I 2 34,57 Stringof integers

    programming

    math

    if A is a substring of B all elements of A occur in Be l z s e 7 I z 4

    allelementsof a occurfirstin Be l z I 2,2 6 it

    allelementsof a occur castin Bl z e 814 I z

    o Buck

    a functionthatcallsitself

    youmustpass a smallersubproblemto successive methodcaus

    basecase it is thesmallest subproblem wecansolve

    if basecasecondition this can always differreturn some basicvalue but this isjust a classicelse

    ycan method again w smaller subproblem satyggwn.mnmtor

    a recursive

  • Treat asone atomic step line stepover indebugBased on method contract

    I

    exponent 0 return I nexponent1 powerCh exponent Dexponent 0

    implements

    extends

    extends

    all

    super

    0 all

    Override above methodsignature

    yes withsuper

    21 methods withsame method namebut differentreturn types andorparameter types andor numberof parameters

    simpleWriter Simplewriter'LL

  • NaturalNumber NaturalNumber2

    have it be an interface

    polymorphism

    yes add subtract multiply for NNs

    confidence building

    determining if we cansolvethe problem or need to create a subproblem

    it is a subtree

  • We disallow the caller to compute 2 or 1results in infinite recursion how

    if n 3 then return fibl2 fibli6thiswilltryto compute fibli t fiblo

    brecursion doesn'texist

    unittesting

    integration testing

    systemtesting

    regression testing

  • Unit under test

    i

    a memo is incorrectIs

    testing noknownbugs debugging knownbugrunentiremethod stepthrougheachlineofcodeevaluateoutput evaluate intermediate states

    no

    testplanIfxture

    8

    toIntl0 BtoIntl17 RtoIntl0 CtoIntl A RlctoIntl Rlc

    tointtrueRlctoMtfalseRlc

    0.0000005B ctoIntel0000000 Rtointlo99999999999999999 RKtoint13.14159 RtointHdoublematn.powcz.sn loBIRK

  • no wedon't allow negative inputs

    no we don't have a methodfor strings

    yes boundary

    yes boundary

    yesroutine butwill it return 5 or correctvalue of 53lookat ASCHtable

    no we don't have a methodfor NNS

    Testpublic staticvoid testTolntWithNumericalChar1

    charinput oint expected 48int actual toIntlinputsAssertEqualsexpectedactual

    Testpublic staticvoid testTolntWithFalse

    Boolean1boolean input false

    int expected Oint actual toIntlinputsAssertEqualsexpectedactual