《2012考研专业课自测试题及答案计算机组成原理.ppt
文本预览下载声明
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ListInsert—移动 L 7 7 a1 a2 a3 a4 a5 a6 a7 a1 a2 a3 a4 a5 a6 a7 表满的条件? length=listsize 10 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. ListInsert—移动 if(L.length == L.listsize){ newbase = realloc(L.elem, (L.listsize+LISTINCREMENT)*sizeof(ElemType); if(!newbase) return(OVERFLOW); L.elem=newbase; L.listsize +=LISTINCREMENT; } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. ListInsert Status ListInsert(SqList L, int i, ElemType e){ if( i1 || i L.length+1) return(ERROR); if( L.length = = L.listsize) { newbase = realloc(L.elem, (L.listsize+LISTINCREMENT)*sizeof(ElemType); if(!newbase) return(OVERFLOW); L.elem=newbase; L.listsize +=LISTINCREMENT; } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. ListInsert q=L.elem + (i-1); p=L.elem + L.length-1; while( p=q){ *(p+1)=*p; p--} *q=e; L.length++; return(OK); } 移动 赋值 长度增加 for(int j=L.length-1;j=i-1;j++) L.elem[j+1]= L.elem[j]; L.elem[i-1]=e; ++L.length; Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. ListInsert 1、在什么情况下,移动次数最少,最少移动次数是多少? 2、在什么情况下,移动次数最多,最多移动次数是多少? 3、在插入每个位置的概率相同的情况下,移动次数的期望值是多少? Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. List Delete—功能 原型:Status ListDelete( SqList L, int i, ElemType e) 作用:取出线性表L的第i个数据元素的值,并删除 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. ListDelete—功能 逻辑结构的变化 ai-1, ai ai, ai+1→ ai-1, ai+1 (a1, …, ai-1, ai, ai+1…, an) → (a1, …, ai-1, ai+1, …, an) Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 20
显示全部