版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
單鏈表的遞歸算法舉例
單鏈表的遍歷(正序或逆序打印)
打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn)在單鏈表中查找某元素求元素的前驅(qū)或后繼求單鏈表的長度判斷單鏈表元素是否遞增(遞減)有序求單鏈表元素的最大值和最小值求單鏈表所有元素之和建立單鏈表在單鏈表中插入元素刪除單鏈表的元素線性表的抽象數(shù)據(jù)類型數(shù)據(jù)對(duì)象:數(shù)據(jù)關(guān)系:基本操作:ADTList{InitList(&L);//初始化
DestroyList(&L);//銷毀
ClearList(&L);//清空
線性表的抽象數(shù)據(jù)類型(續(xù))(5)ListLength(L);//求表長(6)GetElem(L,i,&e);//取元素(7)LocateElem(L,e,compare())//查找(8)PriorElem(L,cur_e,&pre_e);//求前驅(qū)(9)NextElem(L,cur_e,&next_e);//求后繼(4)ListEmpty(L);//判空,yes=TRUE線性表的抽象數(shù)據(jù)類型(續(xù))}//ADTList(10)ListInsert(&L,i,e);//插入(11)ListDelete(&L,i,&e);//刪除(12)ListTraverse(L,visit());//遍歷減治法(Decrease-and-Conquer)PlutarchsaysthatSertorius,inordertoteachhissoldiersthatperseveranceandwitarebetterthanbruteforce,hadtwohorsebroughtbeforethem,andsettwomentopullouttheirtails.OneofthemanwasaburlyHercules,whotuggedandtugged,butalltonopurpose;theotherwasasharp,weasel-facedtailor,whopluckedonehairatatime,amidstroarsoflarghter,andsoonletthetailquitebare.
-E.CobhamBrewer,DictionaryofPhraseandFable,1898減治法(Decrease-and-Conquer)減治法利用了一種關(guān)系:一個(gè)問題給定實(shí)例的解和同樣問題較小實(shí)例的解之間的關(guān)系。一旦建立了這樣一種關(guān)系,我們可以自頂至下(遞歸地),也可以自底至上(非遞歸地)來運(yùn)用減治法有3種主要的變種:
減去一個(gè)常量減去一個(gè)常數(shù)因子減去的規(guī)模是可變的減治法的典型應(yīng)用
插入排序圖的深度優(yōu)先搜索拓?fù)渑判蚨媾判驑涞牟檎液筒迦雴捂湵淼哪嫘虼蛴』蚰嬷脺p治法(Decrease-and-Conquer)原始問題的規(guī)模是n子問題的規(guī)模是n-1子問題的解原始問題的解減治法(Decrease-and-Conquer)單鏈表的遍歷(正序打印)a1a2a3a4a5L(1)LL(2)voidListTraverse1(LinkListL){if(!L)return;printf(“%d”,L->data);ListTraverse1(L->next);}L(2)=L(1)->next單鏈表的遍歷(逆序打印)a1a2a3a4a5L(1)LL(2)voidListTraverse2(LinkListL,void(*visit)(ElemType)){if(!L)return;ListTraverse2(L->next,visit);visit(L->data);}按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
6p(2)p(3)p(4)p(5)p(6)=NULL按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
6p(2)p(3)p(4)p(5)p(6)=NULL按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印單鏈表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不帶頭結(jié)點(diǎn)的單鏈表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
113745LpvoidPrint_NextElem(LinkListL,intcur_e,intfound){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn)
if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);Print_NextElem(L->next,cur_e,found);}}13745LvoidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}p13745L1voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)13745L1voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)13745L1voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)13745L1voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)13745L1voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)13745L2voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)L(2)13745L2voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)L(2)13745L2voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)L(2)13745L2voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)L(2)13745L2voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)L(2)13745L3voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)L(2)L(3)13745L3voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=0L(1)L(2)L(3)13745L3voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)13745L3voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)13745L3voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)13745L4voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)13745L4voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)13745L4voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)13745L4voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)13745L4voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)13745L5voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)13745L5voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)13745L5voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)13745L5voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)13745L5voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)13745L6voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)L(6)=NULL13745L6voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)L(6)=NULL13745L5voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)L(5)13745L4voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)L(4)13745L3voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)L(3)13745L2voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)L(2)13745L1voidPrint_NextElem(LinkListL,intcur_e){//打印單鏈表中從某結(jié)點(diǎn)開始的所有結(jié)點(diǎn),//found為全局變量,初始值為0if(!L)return;else{if(L->data==cur_e)found=1;if(found)printf("%d",L->data);
Print_NextElem(L->next,cur_e);}}found=1L(1)voidPriorElem(LinkListL,intcur_e,int&pre_e){
//求單鏈表元素的前驅(qū)元素,
//flag為全局變量,初值為0,查找成功,flag=1if(!L)return;else{if(L->next->data==cur_e){pre_e=L->data;
flag=1;}else
PriorElem(L->next,cur_e,pre_e);}}13745Lp求單鏈表的長度a1a2a3a4a5L(1)LL(2)intListLength_L(LinkListL){
intlen;if(!L)return0;
len=1+ListLength(L->next);returnlen;}13745LL(1)1intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}13745LL(1)1intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(1)=?13745LL(1)1intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(1)=?13745LL(1)1intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(1)=?13745LL(1)2intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(1)=?L(2)13745LL(1)2intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(2)=?L(2)13745LL(1)2intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(2)=?L(2)13745LL(1)2intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(2)=?L(2)13745LL(1)3intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(3)=?L(2)L(3)13745LL(1)3intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(3)=?L(2)L(3)13745LL(1)3intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(3)=?L(2)L(3)13745LL(1)4intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(3)=?L(2)L(3)L(4)13745LL(1)4intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(4)=?L(2)L(3)L(4)13745LL(1)4intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(4)=?L(2)L(3)L(4)13745LL(1)4intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(4)=?L(2)L(3)L(4)13745LL(1)5intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)L(3)L(4)L(5)13745LL(1)5intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(5)=?L(2)L(3)L(4)L(5)13745LL(1)5intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(5)=?L(2)L(3)L(4)L(5)13745LL(1)5intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(5)=?L(2)L(3)L(4)L(5)13745LL(1)4intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)L(3)L(4)MaxValue(4)=513745LL(1)4intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)L(3)L(4)MaxValue(4)=513745LL(1)4intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)L(3)L(4)MaxValue(4)=513745LL(1)3intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)L(3)MaxValue(3)=513745LL(1)3intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)L(3)MaxValue(3)=713745LL(1)2intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)MaxValue(2)=713745LL(1)2intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}L(2)MaxValue(2)=713745LL(1)1intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(1)=713745LL(1)1intGet_Max(LinkListL){
//求單鏈表中的最大元素值
intMaxValue;if(!L->next)returnL->data;else{
MaxValue=Get_Max(L->next);if(L->data>MaxValue)MaxValue=L->data;returnMaxValue;}}MaxValue(1)=713745preLpStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}13745L(1)LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}1pre=NULL13745LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}1pre=NULLL(1)13745LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}1pre=NULLL(1)13745LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}1L(1)pre13745LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}1L(1)pre13745LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}2preL(1)L(2)13745LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}2preL(1)L(2)13745LStatusIsAscendOrder(LinkListL){//判斷單鏈表是否遞增有序,pre為全局變量,初始值為NULLif(!L)returnOK;if(pre)if(pre->data>L->data)returnERROR;pre=L;
returnIsAscendOrder(L->next);}2preL(1)L(2)13
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 流行性感冒培訓(xùn)課件文庫
- 城市運(yùn)行與管理培訓(xùn)課件
- 執(zhí)業(yè)藥師證報(bào)考條件沒有工作經(jīng)驗(yàn)可以嗎
- 活動(dòng)策劃人員培訓(xùn)
- 洛陽五險(xiǎn)一金培訓(xùn)
- 2024-2025學(xué)年四川省高三上學(xué)期12月聯(lián)考?xì)v史試題(解析版)
- 2026年古典音樂欣賞能力測驗(yàn)問題庫
- 2026年高校思政課黨員知識(shí)測試題集
- 2026年網(wǎng)絡(luò)安全防御專家培訓(xùn)題集
- 2026年高難度法律英語案例閱讀理解題集
- 雅思2025年閱讀真題解析試卷(含答案)
- (2025)新課標(biāo)義務(wù)教育數(shù)學(xué)(2022年版)課程標(biāo)準(zhǔn)試題庫(附含答案)
- 金太陽陜西省2028屆高一上學(xué)期10月月考物理(26-55A)(含答案)
- 2025年青海省事業(yè)單位招聘考試教師物理學(xué)科專業(yè)知識(shí)試卷解析
- 成都城投集團(tuán)招聘筆試試題
- 2025年安全生產(chǎn)知識(shí)教育培訓(xùn)考試試題及標(biāo)準(zhǔn)答案
- 2025年廣西壯族自治區(qū)中央遴選真題及參考答案(b類)
- 品牌管理指南的建模指南
- 氣動(dòng)安全知識(shí)培訓(xùn)課件
- 境外傭金管理辦法
- 采購違規(guī)管理辦法
評(píng)論
0/150
提交評(píng)論