版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
解:數(shù)據(jù)是對客觀事物的符號表示。在計(jì)算機(jī)科學(xué)中是指所有能輸入到計(jì)算機(jī)中并被計(jì)算機(jī)程序處理的符據(jù)的一個(gè)子集。的數(shù)據(jù)元素的集合。是數(shù)據(jù)結(jié)構(gòu)在計(jì)算機(jī)中的表示。的一組操作的總稱。一般數(shù)據(jù)類型的擴(kuò)展。據(jù)部分和操作部分時(shí),要求只定義到數(shù)據(jù)的邏輯結(jié)構(gòu)和操作說明,不考慮數(shù)據(jù)的存儲結(jié)構(gòu)和操作的具體實(shí)畫出其邏輯結(jié)構(gòu)圖。)。作:作:m)&,rRmubsNneaonRtltiIi(DestroyRationalNumber(&R)}x)=&]an=)iwhe;i!l}i[(!(kabr*xe)yba=ys=xzea;sc;:(b)y*xa)bs/a-x)ys=uza;ftd(el(:(}。序的維護(hù)較為困難。}}}}}}}=n)+.+3.+2+.+)31.+2+)2+1)5(1(2x2xi=12 }}lognn請判斷以下斷言正確與否:大于50nlog2n的值。i=1i=0nni=1i=1)nzty,nxti,nxtmain3iti({}{}+p=]pj1]+)jk=<0jr;ojf[j[;(}}稱NmeahoEcSlDCAB},mu,n;pfeydet{pTyxeSMeaem}F,emalune;lpfeydet{n)nta,nm]pinetonCmo,Neaohs[SorcmlouemSucS({reocm.aus=]+MmaSipeM.;)leta=xe[el].afsi[(reocm.aus=]+maSFiempe.;letm)Fe[a=xele].afsi[(}}maleSum;mpFem.+uMetSpema=m.luetSTmpaotlte.}{)0xt)-AeirezSk1if>;i(()0NxtTMAe)Xi->I*];a*2if(1i[(}})0xTANt)XMei>]Iaf;i([(}}Pn(x)=xnaixi的值Pn(x0),并確定算法中每一語句的執(zhí)行次數(shù)i=0in)nxtub,eoi,ndl,ta;inm]itanyopilobuielod[l({]an>ic+)n=i=<0ir;of[i;(nd<enx<)l,na,man;yoploi<u<"lsvemain(yloploihTelu<"oc<t}n)nxtub,eoi,ndl,tainm]itanyopilobuielod[l({n*x)x,-a,man1yopi;+loin-n]alurirte)0(f>i[(}點(diǎn)是在首元結(jié)點(diǎn)之前附設(shè)的一個(gè)結(jié)點(diǎn),該結(jié)點(diǎn)不存儲數(shù)據(jù)元素,其指針域指向首元結(jié)點(diǎn),其作用主要是為空表、非空表以及首元結(jié)點(diǎn)的操作進(jìn)行統(tǒng)一處理。N)Leodofemzoc)aiskLL=Lnt;lsi(i((P=L;N)oLdefoemzosc)ainkLt;lL=Psn-xti(e>i((})2*+,L_,kLinL1tisn)is-;i=4Ir=>oif(1i;()L_,kLnLtDis)ie+li=3;r=<oif(i1i;(選擇合適的語句序列。nx-xte>Pn=-tenx>P-te>)2;(n-xtP=e>)Q=n-xtPwe>he);8li!(nxP-=teULN>)=-nxtPwe>;he9)li!(選擇合適的語句序列。nx-xte>Pn=-tenx>P-te>)3;(xPn=-tePLN>U)L=Pwhe)5;li!(x}-nQt=Qe>P=QULN)=-nxt;wQe>he);6li{!(n-xtP=e>)Q=n-xtPwe>he);7li!(xP-netP=Q>)=x-nten-xt>Pwe>;he8)li!(-nxtP=Ne>UL)=x-nten-xt>;Pwe>he9)li!(nx-xte>Pn=-tenx>P-te>);1(uoupr-pr>ouPi=-pr>oPi->)2;i(n-xtP=xe>un-tpre>oP->)9;i(Su=opr-n-xt>Pie>)2;1(S=xun-teopr->P>)3i;1(uoPpr-u=>opir-n-xt>Pi4)e>;1(next;P=-Pxt)>Pwn-he>eli(}})N*qLdeo,N*LeBosdv)o2{i(pnext;-p=>)=xqpwn-the>eli!(}bpNode*)Lap,A(LNode*Avo{id}k)nt,n&tai,LKitSqsDiteueaSlst({)+unoktunc<o=tuncorto{fc1;(m]j=ea-m].lje)ai-[.;l=+jhn[>jig=1tear.of;lj;(}}k)nt,n&tai,LKitSqsDiteueaSlst({BELNASFEIrnur-teI)hn;gtaike.k>l0h-<ngeta1>.0lf<|i|i||(km+]+ji=em.a]+l;ajie.[l[}序性。xm)pTeyE&,veaLltSqsrLtirOsrdeinteusaSstI({urn(OVERFLOW);r)etezs=vathis=.ligntvae.fli(-)-m]iveaix1<.l0h,>nt;g=ve[air.lofi;(m-]=1vem.ai]lveae.;i[l[}&B)LAt&Sq,siLtqSsrLtisrOemprdeaiCouaSst({Bhength;.gnAtlhe.?ntBlhgenA>.lgk=:te.l=m)]Bj1em.iA>]le;if.l[i[(=-m)]Bj1em.iA<]le;if.l[i[(}0=)hnBjgth=e.nAtlge;f.li(}x)pTmyEe&Le,Ll_nkLtmsLiEieaonLctlti({}}&L)L_knLthsLinigLtenLtsti({}}連接運(yùn)算。請分析你的算法的時(shí)間復(fù)雜度。)hc&nkLtbsL&h,ikLtiLn&h,saiL_inkLtsLiLMtiregsveoidi({x)bn-et&p>nxtpw-e>ah{eli(}xn-tbp=e>p)nxtbpw-e>h;eli(}xn-tp=e>ap)nxtpw-e>ah;eli(}}n)net,nlj,ntitbi,iLtkndlsLeai,iLktlsnLdeubiSnrAtinesdDteIueaSls(t{BELAFENSnIurteI)0n;<e0<l0jf<i|(})ne,ntltji,ntb&i,LnktlisL&a,ikLtinLlubsSirnAtinesdDetIueSals(t{BELAFENSnIurteI)0n;<e0<l0jf<i|(}NFEASIBLE;urnrI)ptefi!(}NFEASIBLE;urnrI)teqfi!(}}NFEASIBLE;urnrI)tefsi!(}}鏈表上實(shí)現(xiàn)相同操作的算法進(jìn)行比較。。m)kxampTeyEm,nkepmylTe&EiLe,l_nkLtsLiDiteLtelusSasti({ROErnurkxtem)aknm>;fi(}}}}元素的值均不相同),同時(shí)釋放被刪結(jié)點(diǎn)空間,并分析你的算法的時(shí)間復(fù)雜度。&)LktnLNsmo_ideSaiLeDetLevtlos(di{)a-dvtpr=e>&ap-dt&p>{fi(}}}順序表的逆置L&)_LtSqsSqpopiOesLtusaSsti({+)h/2nigLet=<.0rlo{fi;i;(-]hngLtmi1e.L=emle.;lL]e.il[x-=h-]ntmigLeL1.le.;l[}}&L)_knLtsLpiopiOesLtusaSsti({}})C&nkLtBsL&,iLknAtisL&,iknLt_isLrMigeiLetusSasti({}}表歸并成一個(gè)按元素值遞減有序(即非遞增有序,允許表中含有值相同的元素)排列的線性表C,并要求C&)LtsnkL&Bi,LiLnkAt&si,L_iknLtsLipeoirMOgseLteusSasti({a)b-tpd>a-<tapd>af{i(}}}}}}&)CLt&BqS,siLAt&Sq,siLtq_SqsoirCsLtusaSsti({h)nBget&<.hljgnAtwe.h{<leili(Aem[i]);_,kCe.l,SqnrtLestsIi(}}})C&nkLtBsL&,iLknAtisL&,iLknt_isLoirCisLtusaSsti({a)b-tpd>a-<tapd>af{i(}a)b-tpd>a-t>apd>af{i(}}}}}}&C)LBt&Sq,siLAt&Sqs,L_itmSqsSieaSDeorClsLtusaSs(ti{h)nBget&<.hljgnAtwe.h{<leili(Aem[i]);_,kCe.l,SqnrtLestsIi(}m)A]=eih-.ln]gCtem{1[.Celf!.li[(Aem[i]);_,kCe.l,SqnrtLestsIi(}}}}B&)LAt&Sqs,L_itmSqsSieaSDeorClsLtusaSs(ti{h)nBget&<.hljgnAtwe.h{<leili(}m)A]=eikem.lA]ef.l{[i![(}}}}&C)LktsnL&Bi,LktiLnA&,sikLt_inLmsLieaSDieoCrlsLtusSas(ti{a)b-tpd>a-<tapd>af{i(}a)b-tpd>a-t>apd>af{i(}}}}}}}}&B)kLtnLA&,siLkt_iLnmsLieaSDieorClsLtusSas(ti{a)b-tpd>a-<tapd>af{i(}a)b-tpd>a-t>apd>af{i(}}}}}}}}C表中出現(xiàn)的元素。試對順序表編寫實(shí)現(xiàn)上述操作的算法,并分析你的算法的時(shí)間復(fù)雜度(注意:題中沒值各不相同)。&)CtsL&BSq,iLAt&qS,siLt&SDq,siLtq_SqsnUoinLtuisaSsti({})C&nkLtBsL&,iLknAtisL&,iknLt_isLnUoiniLtuisSasti({}B&)nkLAtsL&,iknLt_isLunMisLtusSaisti({a)-tapd>a-<tabpd>f{i(}a)-tapd>a-t>abpd>f{i(}}}}}&)SL_knLtsCLiDieteLetlusaSsti({REROurnr)nxte=-teS=>;Sfi(}}&L)LknLtDu_sLDiLtsntuaSistI({N)uLdeDofemzosc)a;iLlLnktDlusL=i(i((})pmTeyELe&,knLtDlu_sLDLirinetsLtusIaSsti({N)uLdeDofemzosc)a;iLlLnktDlups=i(i((}&L)LknLtDusDiTroiCLtusaSisti({}}&)L3sLnkt&s2i,LisktsLn&i,LisknLt&sL1i,LikLntsCLin3oivtDdeILtuisSaisti({&p-data<='9'){&>0'=a'>ap-dt>fi(}Z)'=a-<t&apdA>'=a-t>a|pd>fi()='zap-t<&d>=a'ap{-t>d>(}}}}rneoPXr*toNoiX,rdeo};r)qnoPXretopri,noPXrte;oPXroinrPXretoi(元素的值。)rahLd&,cLtsknLdeXroiLinkLtsnigrvaiTsreuiaSs(t{hrt,gpfreti,nlPXreto;iLRPtr);-p>Pf,tpXr=eol(}}})hgrtP,LRtPip->pXr=o;(}}&L)LnktDu_sLDuiLinahgCeLtusaSsti({next;-q=x>n-tepre->q>}}})pemyTe&ELe,lLnktDu_sLDuiLiaLcteoLtskLtDunLis(i{x-netq=>)qrqpf-er>qf-e&;qL>w=qheli!(}next;-pre->xt=q>pn-e>}}}算法(x0為給定值),并分析你的算法的時(shí)間復(fù)雜度。&)LyPoqSntylPouiIaSlst({m)r)TeyoPofl*ezasLt;ism.oc*ma)lrlT(eyoP=aLald(t.(}})0xbue&oLdlP,myoSuqySlPobuelodl({)p+,+aLtisn=<.l0P=0i{,r;i;(*x0=x+)pxjp-e=<>=x;0j,rof1j;(}}&L)2yoP&Sq,LlPyoL&Sq,1ylPSouqnMlyPsouaSlist({)taL&.2s<ljtaswL.h<l{1eili(}}p2-coef){=>f-eop1c>fi!(oef);-2p-c>)of-ce>pf=(p1-eoc>(}}}p-xp=e>p-xe>1;}p-coef;2=->pf-eoc>p-xp=e>2p-xe>;}}NodeyouPrctlpftysdet{yPkonLdelknLyPopifyidet;l&)LyPokndLealnirteDlfeyPiouaSlist({}pxe.ap-d*t>ofceap-t.;=d>ofeap-ct.ad>}}}&)LPyonkLd1e&l,yPoinkLdelCL2noivtDdeILtuisaSisti({xp%2==0){ae.ap-dt>fi(}}}}得到或者如何得到(即寫出以‘S’表示進(jìn)棧和以‘X’表示出棧的棧操作序列)。{}prntf(y);pS,y);oPi)m)ySpEkwtaShcte(li{(!(printf(x);}‘k’;‘s’);k)ScaStaougat)ls1ts1(({A)n}p,]SoP+n)m)ySpEk;wt[aShct(e;li{(!(A)h]SuP,)isn+=r=<;oif[i1i(;(})nkteS,caSitaou2gat)l2sts(({while(!StackEmpty(S)){}while(!StackEmpty(T)){}}試給出區(qū)分給定序列為合法序列或非法序列的一般準(zhǔn)則,并證明:兩個(gè)不同的合法(棧操作)序列(對同一輸入序列)不可能得到相同的輸出元素(注意:在此指的是元素實(shí)體,而不是值)序列。列為:npj<pk<pi,則可以理作數(shù)棧和運(yùn)算符棧的變化過程:輸入字符主要操作1#2#A3#A4#B5#B6#7#G8#G9#H1#II##K#{}{}}3.10試將下列遞歸過程改寫為非遞歸過程。voidtest(int&sum){intx;cinx;if(x==0)sum=0;se{test(sum);mx}cout<<sum;}{m)pyEsktawcShte{li(!(}}同點(diǎn)和差異處。解:棧是一種運(yùn)算受限的線性表,其限制是僅允許在表的一端進(jìn)行插入和刪除運(yùn)算。3.12寫出以下程序段的輸出結(jié)果(隊(duì)列中的元素類型QElemType為char)。voidmain(){QueueQInitQueueQ);charxe’,y=‘c’;EnQueue(Q,‘h’);EnQueue(Q,‘r’);EnQueueQy);DeQueue(Q,x);EnQueue(Q,x);DeQueue(Q,x);EnQueue(Q,‘a(chǎn)’);While(!QueueEmpty(Q)){DeQueue(Q,y);couty}coutx;}3.13簡述以下算法的功能(棧和隊(duì)列的元素類型均為int)。voidalgoQueue&Q){intd;ackSwhile(!QueueEmpty(Q)){DeQueue(Q,d);Push(S,d);}ileStackEmptyS{PopS,d);EnQueue(Q,d);}}{}x)pemyTEe,ntluPhivoisdi({=-xp0*]op=t)p>0];oft[i[(wr"ofvokealctSr<"c!e;esl}=xp]o*+-t)1kezapsc1t;+ip<[s]oft1i[(wr"ofvokealctSr<"c!e;esl}}{p]o0*+urntrte)p];op<t[01]ofti[(-p*]ourntr1te)0p];opt[>]oft1i[(}}/鏈棧的數(shù)據(jù)結(jié)構(gòu)及方法的定義pTNeydeourtctpfeysdet{{}&)kscaSktarctySDovteosdi({}}&)kaskctSrcaSCtaveodli({}})kahsctSnLtgkeanctSti({})kcmaSpstyEktacSutaSst({UETRurnr=te)0ez;fs.isi(}{}})pTemyEe&e,kalhsctSuPusaSst({}&)pemyTe&Ee,kalpscSPtouaSst({}})pmTeyEe)V*tlusaitS,sktascSr(vetTkreas(aScvtodi({}寫算法,輸出對這n節(jié)車廂進(jìn)行調(diào)度的操作(即入?;虺鰲2僮?序列,以使所有的軟席車廂都被調(diào)整到{}}}}{&)&]ai'='w]ahei{[li![(}i}}})r]ahyncpncdeoroskCe[BrteBaLcO({}}E;AFLSurnr=0)teezf(ss.ii!}色區(qū)域的點(diǎn)。hk"c.VaSCt9\ud"\nd#ecli:NM)]pm]TgeyEeSDGrCeta;lve[odi(NM)]pgm]yTeEAeyahr;lpGwr[ah[Sovodi()wrNoCelntuP,ropsC;TiNeyoPM,s]pm]TgeyEegnFnloR[ligveoidi({r)CoFPlo,ralistSg,n;FgnRloigeli(}r)CoFlntluPi,ropsCTiNeyoPM,s]pm]TgeyEegnFnloR[ligveoidi({or;Co].ylCurPos.x].CurPosgr=oContdOl[li[y)Pr].ouCsx]ouPCr.s;uPhg,s[[(m)pyEsktawcShte{li(!(}}NM)]pm]TgeyEeSDGrCetalve[odi({roCFr=loCloi.yuPr].;losCxP]ouCr.gs[=Vdte1.yuPisr].oisCxP];ouCr.gs[&VdetyPsr].ouiCsx]+Pr.ouCgs1[![roCo=dOrloCylP].louCr.sx+P]ouCr.gs1[[))]youPCr.s+x]ouPCr.s1;uPhg,s[[(&VdetyPsr].ouiCs-x]Pr.ouCgs1[![roCo=dOrloCylP].louCr.s-xP]ouCr.gs1[[))]youPCr.s-x]ouPCr.s1;uPhg,s[[(&Vdet+s].youPiCr.s1xPr].ouCgs[![roCo=dOrloCl].+yluPr.osCx1P]ouCr.gs[))]y+Pr.ouCsx1]ouPCr.s;uPhg,s[[(&Vdet-s].youPiCr.sx1Pr].ouCgs[![roCo=dOrloCl-].yluPr.osCx1P]ouCr.gs[))-]yPr.ouCsx1]ouPCr.s;uPhg,s[[(}}NM)]pgm]yTeEAeayhrlpGwr[ah[Sovodi({}})r]BufehfrancorEpxeisnd[aoPrnvelsveo(dIi{#)'=r]Bufwehife{li![(}}}}}m)pyEsktawcShte{li(!(}}{}})2hrcach,rcarcoPr1uaSist({+=)c&hi&]c1ihw];hcie![li[(+=)2jc&h&]jchw];jhce![li[(})rBue]hfranPdcao_nrve[ValCahrIalcl({#)'=r]Bufwehife{li![()r]BufreiraopOtef{s[Ii(!(Push(Opnd,Buffer[i]);})2,re]Buefi,=Ceac;1l[(}}})2hrcapcoh,rach,rcaCcahr1acl({}}hna"nt.DoCtVSsC9\ud"\nd#ecli:pTNeydeourtctpfeysdet{&)kaskcStaSnctvtodI;i()pTemyEe&e,kalhsctSuP;usaSst()pemyTe&Ee,kalpscSPt;ouaSst(r)hcarcaoprOteua;SstI()kcmaSpstyEktacSuta;Sst()r]ahancaPrdoFTvlon;u[aSstI({nd<ealut<oc)anaPrd;oFTvlonfIi((})r]ahancaPrdoFTvlonu[aSstI({}}ASE;FLurnrt)em)ypEsktactSfi(!(}{})r]araopiOtefs{Ii[(!()=9'&<]a0i'=>]a{fi[i[(}}}}}{})pTemyEe&e,kalhsctSuPust()pemyTe&Ee,kalpscSPtouaSst({a)p-td>ot.yp,srect;s(}})kcmaSpstyEktacSutaSst({UETRurnr=te)0ez;fs.isi(}{}}{ndmn<e)l,ug<o=ct)0n;f>i((}{}303132338344052{}}AAe)beueop,dlbuAeodlub,e;ordtSlbuqeodl({ndpA<e)l,e,rtSuq<oct<;(})beueop,dlubAeodlub,eordtSlbuqeodl({A)p-e<)p*&-A)p-*e>pfi(()A/2p,/e)pA+,rntSuqr;te(}(n+1m=0akmmnakm(m-1,1)m豐0,n=0n)ntndemuig,snintugndemikasnintundeigsi({)-m,krnaur1=te)0n=;fi((}}{}}if(StackLength(s)>1){}=0);vmae.lngth(s)!=1kLeawc!Shte}|l|i(}m)2,k0=m)ag-m,kmak=a=1;2m)0,k(a=-m)n1m,k=(ag1;(退=3m)2,k0=ma)g-m,kmak=a;=12m)0,k(a-=m)n1m,k=(ag1;(棧)m,k=3maka1m(2,0)=3;k=ag()m,k=3maka1m(2,0)=3;k=ag()m,k=3maka1m(2,0)=3;k=ag(m)02,ka=m)g,-mka1m(1,0)=2;k=ag(()m,k=3maka1m(2,0)=3;k=ag()m,k=3maka1m(2,0)=3;k=ag(m)0,k3a=m)g,-mka=)31m,k=ag(1(;()m,k=3maka1m(2,0)=3;k=ag(02)1m2,ka0,1()m,k=3maka1m(2,0)=3;k=ag(a,136)m,k31(4)m0,ka=m)g,-mka1m(1,2)=4;k=ag((02)1m2,ka0,1()m,k=3maka1m(2,0)=3;k=ag(列何處隊(duì)列的算法。pTNeydeourtctpfeysdet{{})pemyTeEe&uq,luQeuQeEneuaSst({}rnext;-r>axt=qe.pn-e>}}{AELSFrnur=te)0ez;qfs.i(}pnext;-=x>nr-ter>aqe.}}并從時(shí)間和空間角度討論設(shè)標(biāo)志和不設(shè)標(biāo)志這兩種方法的使用范圍(如當(dāng)循環(huán)隊(duì)列容量較小而隊(duì)列中每個(gè)種方法較好)。{QMxez]aSpmTiweyEen=;bealq.s[ELASFnurte)bea.qfs;i!(})pemyTeEe&uq,luQeuQeEneuaSst({}}&)pemyTeEe&uq,luQeuQeDeueaSst({EASFLurnrt)ge&aqrt.r;a=e.qnrtofqf.!i(}}EASFLurnrt)e&agrt.qr;a=e.qrntofq.(r+1)%MaxQSize;rar=(qe.raqe.=agt)qnr1t.of=qr.ae;qf.i(ront+1)%MaxQSize;qfn=.rtoqf.(個(gè)數(shù)。試給出此循環(huán)隊(duì)列的隊(duì)滿條件,并寫出相應(yīng)的入隊(duì)列和出隊(duì)列的算法(在出隊(duì)列的算法中要返回隊(duì){QMxez]aSpmTiweyEen=;bealq.s[ELASFnurte)bea.qfs;i!(})pemyTeEe&uq,luQeuQeEneuaSst({)QSMxe%za)ihngtq-e.QMxezSalr+airq=e.QMe%Sxzar)+irae.qf1(i(}}&)pemyTeEe&uq,luQeuQeDeueaSst({r)ra=e.qQMe%Sxzah)ignt-e.qQMxezSlra+raie.qfi(-ength)%MaxQSize];qMaxQSize.lr+areq.ab=qese.([}}則不是回文。試寫一個(gè)算法判別讀入的一個(gè)以‘@’為結(jié)束符的字符序列是否是“回文”。)pr*hanrcgrmyStiteySuaSst({0urnrte)uqnQet;fiIi(!(}m)pyEsktawcShte{li(!(ASE;FLurnrt)=e2efei1!(}}{WO)FERLVOxte)0u,uqinQe;Eef(i(!(}WO)FERLVOxte)u,uqinQe;E1ef(i(!(}}}Mxe%z]aS)qi-.MxezaS;+qr1.aiebq.aneuqsr.et[(}尾。)nezt&uqi,sDuQeuiDQentuaSistI({M]Sxezapm.qTiweyEen=;bealq.s[ELASFnurte)bea.qfs;i!(}aStm)pTeyE&,euqQelDueDuQeEneust({EASFLurnrt)e&agrt.qr;a=e.qnrtofqf.i(Mx%qze;aSr.)+irar=(qe.r1aqe.=agt)qnr1t.of=qr.ae;qf.i(})/)2x]SMe%zaqi-.)MxeS{zaqr1.+aireq.abe+qsn.ort]qf.abeqs([.fe<i[(Mx%qze;aS-.)iMxeSzaqn1.+oirtqf=n.rtoqf.(=agt)qnr1t.of=qr.ae;qf.i(}Mx%qze;aSr.)+irar=(qe.r1aqe.=agt)qnr1t.of=qr.ae;qf.i(}}}&)mTpeyE&,euqQelDueDuQeDeueaSst({EASFLurnrt)ge&aqrt.r;a=e.qnrtofqf.!i(MSx%qze;a.)in+ortqfn=1.rtoqf.(}}uh"uQe.VCe9D\u"\nd#ecli:{a)gqrdt.arq=e.nrdtofwqh{d.el|i!(}}{h]uct<)oPi=c'=h];fc[i[(}a)gqrdt.arq=e.nrdtofwqh{d.el|i!(}})2,n37bgsrSut)Si,5gnr3bus1tS(i,nCtaoc((設(shè)計(jì)題:b&)ongrSntoigsnrcSt;i(nit);*hraciString(const)rntgnSAtigrSsvtoid;i()ringtmSprtearConttS;i(nten);,rtalnttisnbgrSuitSignrSti(b&)ongrSntoigsnrctSgnrSiti(:{]+MxezaSwrah1ihn=ce;[})n*thraincitogsnrctSgnrSiti(:{]+MxezaSwrah1ihn=ce;[}}{]+MxezaSwrah1ihn=ce;[}{})nrtgnSAtigrSsntigrSvtodi(i:{})nrtgmSprteairCotSgnrntSti(i:{}{})gnrtaSnCtoincgrSvtodi(:{uren;rlen+tc.lun=urccel}n)nte,rtalntisntbgrSuitSinrgSgrntSit(i:{)n&0e>nur=elnclr<e&+a{t&l=t0srat>ftsi(})+,+jnr<ei=tal=t0i,srojf;i;({}&)gnrstSrveisrReSvtodi({),nbgrSui1tSi.asnCct;ot.((})0,)01,10,)0,10,1)0,(0,1)0(10,)0,(10,1)0,(1,)0,(0,1()0,)10,10,1)0,10,1)0,(0,1)0(12,)02,(10,1)02,(1,)02,(0,1()2,)12,10,1)2,10,1)2,(0,1)(1,1),(10,1)10,(1,1),(10,1()2,)21,10,)2,10,1)2,(0,1)2(10,)02,(10,1)20,(1,)02,(0,1()2,)2,10,1)202,1,)2,(0,1(2(22間也較大。{*)-d+a+-)in1ur1is1te;((}{}{}{}k)n&,LtLtqiSusrctoPindti({)kLM+,xak1m<]Lef.li([()kLM+,nk1m>]iLef.li([()k-mau,Sk1m+]nLeur.;lte([)k-mau,Sk*1m]nLeur.;lte([}k)n&Lt,LiAtSqgsvbuieodl({k+)/m)k]L1ek*e.+)k-;l,Avagnur(1[te(}n)nkt,nAtip,m]yTieEMveRelovod[i({}}})CSRA]Spm]TeyEe;,C]SR[]Salp[yTNeodezan[vt[loidIi()SC]SR]apTNyeondePt;oe[aSidv[lodi(k)nt,C]SR]SaipyTNe;owndMeRopm[yiETe[el(k)nt,C]SR]aSpiyTNe;odMxeaCopm[yETe[lel({})CSRA]Spm]TeyEe,C]SR[]Salp[yTNeodezan[vt[loidIi({})SC]SR]apTNyeondePtoe[aSidv[lodi({}C)SR]S]apTNeyweohd;Sod[(}})=ye&].aj=x]=ie].]ajf[i[i[(}}}}k)nt,C]SR]aSpiyTNeodMxeaCopm[yETe[lel({}}C)SR]S]apTNeyweohdSovod[i({ndn<elpt"oeaida;ls"s<ji<"u<oct<i}b)pTrer<aloiprtBoLOe;(b)preT=raloiprtBoLOe;({}b)preT=raloiprtoepTreBLOli(:{}b)pTrer<aloiprtoepTreLli(:UE;TRurnw)rw<brteor.ofi(UETRurnrte)obc&w<.;lowrclob=.rofi()ob=c&.lowcwrlob=.rofi({Ma)}rtpCeaSs~rtualv{i(n)nt,ntcri,ntMita;prCeaSis(B)MatrpCeaSsr+orapMatte;oprCeaSs(DpC)DC*CpwreaShsSov;odi(n)nt,ncirt,nMtitapreaSisCMtaprCeaSs(:{_Trnm]spTwre_nmlp=eit;[KO)D=Ma)IDodlg.fd{1li((_mow;nR.ow=dlg1_rmp].ti[_mol;nC.ol=dlg1_mpc].ti[m_Enme=.l_gdmp1e].lt;i[}}}DpC)DC*CpwreSahsSoMartpCeaSsvod(i:{w+)_Rmoni=<0nrtoi{fi;i;(+)_Cmojn=<l0njrtoj{f;i;(=)=oj_kcmp&].lwt=ro_p{km].it[fi[(_,k]etr,10);mps.taoti[(})rntsre,tl0,s*t+2s;02,*+0ui(OjTxtDpC-te>(}}}B)MartpCeaSsr+orapMetoapretaCMSstaprC(eSas:{)0_,wnCmo_,nRmlopMtet;aprCeaSs(_m)onCB=l_Cnm.ow_mlonRBw=_nR!m.of|i|!(_Trs];mnB_rm.+TnpsTwre_n=mlpempitet.[mp;urnte_rtm)pempte.fti!(_rs;mTnB_+Trnm._sr=mTnmpset._Trm)nBs&._<jTrnmwsh{<eili(_mpBj]){t_p<m].tfi[i[(w;ro_mpw].r=to_ik]mpmp.tet[.[ol;_cmp].=to_ik]cmpmp.ltet[.[_pem].=t_kemipm].ptet.;[})_mpt]Bj=._pm]tfi{[i[({w;ro_mpw].r=to_ik]mpmp.tet[.[ol;_cmp].=to_ik]cmpmp.ltet[.[_pem].Btj.+_pem].=t_kem;pim[].ptet.[}w;ro_pm].Bwtjr=.o_k]mpmp.tet[.[ol;_pcm].Btj=.o_k]cmpmp.ltet[.[_emp].Bj=t_k]em.pmp.t;et[.[}}}w;ro_mpw].r=to_ik]mpmp.tet[.[ol;_cmp].=to_ik]cmpmp.ltet[.[_pem].=t_kemipm].ptet.;[}w;ro_pm].Bwtjr=.o_k]mpmp.tet[.[ol;_pcm].Btj=.o_k]cmpmp.ltet[.[_emp].Bj=t_k]em.pmp.t;et[.[}}n)nt,ntcri,ntMita;prCeaSis(Ma)}rtpCeaSs~rtualv{i()nj,ntpiwreaShisSoiv;odi(n)nt,ncirt,nMtitapreaSisCMtaprCeaSs(:{_em.pt]>o_icm>p].lnt;ic[>i[}}})nj,ntpiwreaShisSoiMartpCeaSsvod(i:{urnrt)_nCemow_m>lojnR;f>i|(}sd=rpos[i+m];while(d<0){}}while(k<d){}}}{}ght,*down;rNode*LOistruct}{n)n,ntrcti,nMtaiLt;irCosis(M)}taLtsrCos~auirvtl{(i)ntj,nMwtahitSoiv;odi(n)nt,nrcti,nMtaiLtirtosCMisaLtrCos(is:{w];_nRmoknwLOn=HReaide[_nCm];oknlwLOn=HCeaide[p-e>opw->c>lopr->n>;c>i}p-col){<&>o-c&>qwlhile(q}}}row){pw-r<&>o-&>qwhile(q}}}})nj,ntwMtaihtoiMSitaLtsrCosvoi(d:i{}ght,*down;rNode*LOistruct{M)}taLtsrCos~auirvtl{(in)n,ntrcti,nMtaiLt;irCosis(n)nt,nrcti,nMtaiLtirtosCMisaLtrCos(is:{w];_nRmoknwLOn=HReaide[_nCm];oknlwLOn=HCeaide[p-e>opw->c>lopr->n>;c>i}p-col){<&>o-c&>qwlhile(q}}}row){pw-r<&>o-&>qwhile(q}}}}BM)aLtrCosCAisdMtaLtsrCosvoid:(i{ol){bp-c><o-c&&pa>pwalheli(})ob-p=c>l-&opc>alpaf{i(}}}}}}}}wM)ahtoMStaLtsrCosvoid(:i{)=ojp-&wc>l=r-&op>ip{fi(}}}}{)2B,3),A4,3M3aLt;rCosis(}maTgTEeLAMSl}T,OmunI;pfeydet{r)t&STgrnrCtHS,&SintgCrSrt&Si,ntgrSCtrctDirtsntSiti({wh=)0k)2rmpeaosrCSt&{n!.s=|1<|(eili(ubString(i,1);rS=.Sts1+k+)pr3masrCeoSt.;fs1i(!(-k)4mpreasrCotS.;fs1eis(l!(}-)2g,rnubitSr1HSir=t.;St()n-+g,nr1buitSirSiTr=t.;St(}}}&)ngsrC&SLti,LGtGsLtisreanCetiti({)ubTSubHSub,SrctDrtS;sti(hp,HSub);-L>GLtsrCeatei(p,TSub);-Lt>GLtsrCeatei(}}}Str()[0];Get.L->atom=s}}}&L)GLtGswLtihSosvoidi({}}}}{hp);-hL>DptGLethp+Dhs=tHDipete(p);-hLt>DptGLethp+Dhs=tDipTete(hDphTetHDptpheD?Ttphe>H;Dnteur:te}}L&)GTLt&,siGLtsLpGtyoisnCiti({moL-tma=>oT-MtaAO>)T=;agL-t>fi(hp);-hpL>T,-L>pGCtyosi(p);-pLt>T,-tL>pGCtyosi(}}}L&)2GLt&,sLGirtmps1eaoiCGLtusSaist({EASFLurnrt)Le&)2L;&)L&2L1!f1i(|!(KOurnrtm)eaoL-tm2=>o-a;Lt>fi1(}&)ph-pL>2h,-rLm>peaoC1GLtfsi((p)-2pLt>,-Ltrm>apCeoGL1tsi(}}}}二叉樹kkkkkki=1i0kkn=n一n=n0kk i=1i葉子結(jié)點(diǎn)的個(gè)數(shù),li表示第i個(gè)葉子結(jié)點(diǎn)所在的層次(設(shè)根(2)用歸納法證明。ppn問時(shí)BCDEFGHIJKLMN001010011112462710001101113565891018r=-child;r>)lgawr-t>hleli!(序序列對應(yīng)著樹的后根序列。對于子樹先序序列為LNU)L,LNUH)B,CJLNU)E,AD,KFGI((ULN)NU),LHJU),LN,CBLNU),LAE,U)LND,IKFG((NUL),LNU)U),LN)JH,LNU,CBNU),LEA),U,L(ND,IKFG((樹{}}}}}}{urnrNt)v1e)uR],Vt;fsi[(}}urnrNt)v1e)uR],Vt;fsi[(}}}}{}'}g,'f',',e,'db',c;,'a',=N0T'hr]ac{[{nd<e)lTrcN<mueu<oct<;(}{}}{}{}T&)2rBTe&T,TrBieTr1emeaiSuSalisti({})hdT-c>l2hi,l-dTc>liTremlea1Sfli(()hrdT-c>l2hi,r-dTc>liTreme&a1Sli(}}})epTmyEeTeV)tl*usaiTst&S,rBTer(TrveaPis(OuSast({)pmyEsktcSapwthe{li(!(|ROEnRurte)ap-dt>V;tfsi(!(}}T&)BTrek,nt&i,nt&ipi,emyTeKiTENeloPdOeuaSst({)hdT-cl,k>lKi,NPOeoid;()hrdT-cl,k>Ki,NPOeoid;(}}}&)TreBe&,nNmuiNtioiLdeaPfOeuaSst({+)hrdiT-c&l>ih-d;Tc>lifl!i!(-Tchild);Nm>u,NleoPifLdOae(rchild);-TNm>u,NeoPifLdOae(}}{T-child);>TreBlnehEgxeaic(rchild);T->TreBnehEgxeaic(}})hp&ndetxtpT,myEeTie&,rBlTephDrteiTehCduaSlist({if(PreOrderLocate(T,x,T1)){}})&TreBx1epT,myiEeTe&,rBlTeaLrcetoirOePrdeuaSst({})T),xh,dT-c1l>alirLcetorOePrdefi(()T),xh,rdT-c1l>airLcetorOePrdefi((}}}}求二叉樹的深度{T-child)+1;hp>BlDTtep=deil(rchild)+1;T-hp>BDTtepr=dei(prpdepde?prdelne>urd;:tel}})pxmTeyTEe&T,TreBleTreihCdDlueaSlist({}x)h,-dTc>liTrelhCdDlfeli((x)h,r-dTc>liTrehCdDlfeli((}}}}{}}&)TreBT1e&,rBiTeTrBpeyiCouaSist({-child);>lhild,T1T-c>TreBlpCeyoi(rchild);->rchild,T1T->TreBpCeyoi(}}}pmyTeEQeTreBlepfeyidet;huQe."uende\Yncl\uic"\ind#ecli:)pmTeyEeTV)lt*usaTist&S,rBTer(Trveaisr(dvOeLeueSals(t{)h-dpc>luqi,lEnQe;)hdp-c>lifl(i()hr-dpc>luqi,EnQe;)hrdp-c>lif(i(}})*mqpTeyTEp,ep*mlTeyETe&,mTpeylTE&TeT,rBlAentmCncMoisuaSsti({REROurnrTte)T,reB;p1eyoCifi(!(a)-t2T=d>aT-dt&>&2T{Tw1he1li(}}}REROunrTte)2T,reB;peyoCi(!(}}}p)p*mTeyETe&T,TreBlehTrePitauaSst({)h-dTc>BliTrelDe;)hidlT-c>lifl(i()hr-dTc>BliTreDe;)hirdlT-c>lif(i(})hr-dTc>BliTreDe;)hirdlT-c>lif(i(})h-dTc>BliTrelDe;)hidlT-c>lifl(i(}}}T&)rBTeTrBemipetCeouiaSlst({rchild);hT->DpBT-te)hdTih-c>lDpiBlT=(etdi(ROERurnrt)ed>0;fd1<i|(&)hdT-clTr>BliempetCeoifli((KOurnrt)e)hrdT-c>liTreB;empCeteoil(}}}T&)rBTerpETwxeBisohSuaSist({a)aT-dt>a,a-dt>hwdT-c>li{Llofi(T-child);>prlETswxeBhsSoi(})h-dTc>liprxBlETsweh;Soiesl(}a)aT-dt>a,a-dt>hwrdT-c>li{Lofi(rchild);T->prETswxeBhsSoi(})hr-dTc>liprxBETsweh;Soiesl(}}}}{UERTnrurte)'=/b';*b'=&-)'=a'=+|'af(i|(}T&)BTrevhTreiTreBineti({})2pmyEsktc&aSt)myEp{skta(c1tSfi(!(while(!StackEmpty(s1)){rchild);p-h,>uP2s)hsrdp-c>lifi((}})2pmyEsktc&Satm)p{yEskta(c1Sf!ti((while(!StackEmpty(s2)){p-child);h,>luPs)hsd1p-c>lifli((rchild);p-h,>uPs)hsrd1p-c>lifi((}}}}=nm]xai)nxm]<aif;[i[(T&)BTrerBhTePiMxatauiaSst({)=)h-dhTc1>DlTpitBl-e)hT!DpTtBief(i()hdT-clTr>BlihMePxta;i()=)h-rdhTc1>DlTpitB-e)hT!DpTtBief(i()hrdT-clTr>BihMePxta;i(}}T&)rBTeTrBhePiMxtaLuiaSst({)=)h-dhTc1>lDipTtBl-e)hT{DpTtBief(i(T-child);>TreBlhMeaPLxtai(})=)hr-dhTc1>DlTpitB-e)hTDpTtBief(i(r
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 高效節(jié)能電動機(jī)相關(guān)行業(yè)投資方案
- 輕油蒸汽轉(zhuǎn)化催化劑相關(guān)行業(yè)投資方案
- 國慶節(jié)學(xué)生游戲活動方案
- 染鞋行業(yè)營銷策略方案
- 2022年公司元旦活動策劃方案7篇
- 被動防護(hù)網(wǎng)施工專項(xiàng)方案
- 體檢科主任先進(jìn)事跡(7篇)
- 二級職稱專業(yè)技術(shù)工作總結(jié)(5篇)
- 企業(yè)舉辦年會總結(jié)主持詞結(jié)束語
- DB12T 487-2013 放射性同位素與射線裝置安全使用管理制度編制規(guī)范
- 22G101-1與16G101-1的圖集差異
- 《針織學(xué)》期末考試試卷附答案
- 特種設(shè)備使用登記表(范本)
- (完整版)5以內(nèi)的加減法(可直接打印)
- 智能物流-完整版課件(全)
- 新疆準(zhǔn)東經(jīng)濟(jì)技術(shù)開發(fā)區(qū)西部固廢處置場項(xiàng)目環(huán)評報(bào)告書
- GB∕T 36008-2018 機(jī)器人與機(jī)器人裝備 協(xié)作機(jī)器人
- (新版)保衛(wèi)管理員考試題庫(含答案)
- 信貸法律基礎(chǔ)知識培訓(xùn)講座PPT
- TCECA-G 0171-2022 零碳工廠評價(jià)規(guī)范
- 光與色的世界(課件)
評論
0/150
提交評論