




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
单链表的递归算法举例
单链表的遍历(正序或逆序打印)
打印单链表中从某结点开始的所有结点在单链表中查找某元素求元素的前驱或后继求单链表的长度判断单链表元素是否递增(递减)有序求单链表元素的最大值和最小值求单链表所有元素之和建立单链表在单链表中插入元素删除单链表的元素线性表的抽象数据类型数据对象:数据关系:基本操作:ADTList{InitList(&L);//初始化
DestroyList(&L);//销毁
ClearList(&L);//清空
线性表的抽象数据类型(续)(5)ListLength(L);//求表长(6)GetElem(L,i,&e);//取元素(7)LocateElem(L,e,compare())//查找(8)PriorElem(L,cur_e,&pre_e);//求前驱(9)NextElem(L,cur_e,&next_e);//求后继(4)ListEmpty(L);//判空,yes=TRUE线性表的抽象数据类型(续)}//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)减治法利用了一种关系:一个问题给定实例的解和同样问题较小实例的解之间的关系。一旦建立了这样一种关系,我们可以自顶至下(递归地),也可以自底至上(非递归地)来运用减治法有3种主要的变种:
减去一个常量减去一个常数因子减去的规模是可变的减治法的典型应用
插入排序图的深度优先搜索拓扑排序二叉排序树的查找和插入单链表的逆序打印或逆置减治法(Decrease-and-Conquer)原始问题的规模是n子问题的规模是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){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
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){
//逆序打印不带头结点的单链表的元素
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){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
5p(2)p(3)p(4)p(5)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
4p(2)p(3)p(4)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
3p(2)p(3)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
2p(2)按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
1按逆序打印单链表的元素a1a2p(1)a3a4a5StatusInversePrint(LinkListp){
//逆序打印不带头结点的单链表的元素
if(!p)returnOK;InversePrint(p->next);printf(p->data);returnOK;}//InverseList_L
113745LpvoidPrint_NextElem(LinkListL,intcur_e,intfound){//打印单链表中从某结点开始的所有结点
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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){//打印单链表中从某结点开始的所有结点,//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){
//求单链表元素的前驱元素,
//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等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农村水渠建设合同范本
- 2023-2024学年人教版高中信息技术必修一第二章第三节《程序设计基本知识》教学设计
- 承包农家果园合同范本
- 劳务住宿合同范本
- 4 公民的基本权利和义务 第3课时 国家尊重和保障人权(教学设计)2024-2025学年统编版道德与法治六年级上册
- 7 什么比猎豹的速度更快 教学设计-2024-2025学年语文五年级上册统编版
- 幕墙玻璃施工合同范本
- 9心中的“110”(教学设计)-部编版道德与法治三年级上册
- 9 猎人海力布教学设计-2024-2025学年五年级上册语文统编版
- Module 1 Unit 1 Food and drinks?(教学设计)-2023-2024学年牛津上海版(试用本)英语五年级下册
- 07J912-1变配电所建筑构造
- 纠正冤假错案申诉范文
- 锂离子电池串并联成组优化研究
- 宁夏闽宁镇:昔日干沙滩-今日金沙滩+课件-高教版(2023)中职语文职业模块
- 2023-2024学年六年级科学下册(青岛版)第2课 预防近视(教案)
- 大酒店风险分级管控和隐患排查治理双体系文件
- 解剖学知识点
- 成人手术后疼痛评估与护理-中华护理学会团体标准(2023)课件
- TD/T 1038-2013 土地整治项目设计报告编制规程(正式版)
- 2024年湘潭医卫职业技术学院单招职业适应性测试题库含答案
- (高清版)JTGT 3610-2019 公路路基施工技术规范
评论
0/150
提交评论