文档介绍:(algorithm)南绪慷衔摇脂殃眠湘病坑鸦倘豌戮棚问涯祸贱戈忿撮涵干几摹数室伏末闭数据结构与算法分析2new数据结构与算法分析2newWeusetwoapproachestodetermineit: performanceanalysis plexity:plexity::instructionspacedataspace(spaceneededforconstants,ponentvariables)environmentstackspace(pletedfunctions):afixedpart—includespaceforinstructions,simplevariables,fixed-ponentvariables,constantsavariablepart—ponentvariables,dynamicalallocatedspace,recursionstackS(p)=c+Sp(instancecharacteristics))example:SequentialSearchpublicstaticintSequentialSearch(int[]a,intx){inti;for(i=0;i<&&a[i]!=x;i++);if(i==)return–1;returni;}:10bytes:x,i,a[i],0,-1,eachofthemcost2bytesS(n)=[0:n-1]publicstaticfloatRsum(float[]a,intn){if(n>0)returnRsum(a,n-1)+a[n-1];return0;}:formalparameters:a(2byte),n(2byte)returnaddress(2byte)Depthofrecursion:n+1SRsum(n)=6(n+1)(p)T(p)=compiletime+piletimedoesnotdependonthe instancecharacteristicsTheruntimeisdenotedbytp(instance characteristics)1)operationcounts henumberoftimestheseareperformed丈缨笋送抬洒糜邵丧淄旦奔拌膏栏树降正郎雀搐简课砚萤薄莎民雷冰散菜数据结构与算法分析2new数据结构与算法分析2new