数据结构(含课程设计)作业 华工 联系客服

发布时间 : 星期六 文章数据结构(含课程设计)作业 华工更新完毕开始阅读54a5460726d3240c844769eae009581b6ad9bd62

数据结构(含课程设计)·数据结构课程作业

提交方式:附件

一、程序阅读填空 1. 在顺序表中第i个位置插入新元素 x template intSeqList::Insert (Type & x, inti){ if (i<0||i>last+1||last==MaxSize-1) return 0; //插入不成功 else { last++; for( ______int j = MaxSize-1______;j>i;j--) _______data[j+1] = data[j]______; data[i] = x; return 1; //插入成功 } } 直接选择排序的算法 template void SelectSort(datalist& list) { for(inti=0; iviodSelectExchange(datalist& list, constinti){ int k = i; for(int j=i+1;j void List :: MakeEmpty ( ) { ListNode *q; while (first→link!=NULL){ ______q = first ->link___________; ______first->link = q -> link_________; //将表头结点后第一个结点从链中摘下 delete q; //释放它 } last = first; //修改表尾指针 } 4、基于有序顺序表的折半搜索递归算法(Element为有序顺序表) template intorderedList :: BinarySearch(const Type & x, constint low, constint high)const { int mid = -1; if ( low< = high ) { ____mid = (low + high)/2_________; if ( Element[mid].getKey( ) < x ) mid = BinarySearch (_____x, mid+1, high______); else if ( Element[mid].getKey( ) > x ) } return mid; } 5、在顺序表中第i个位置插入新元素 x 。 mid = BinarySearch ( x, low, mid -1 ); int insert(sqlist *L, datatype x, inti) { int j; if (L->n==maxsize) {cout<<”表满,不能插入!(上溢)\\n”; return –1; } if( i< 0 || i>= maxsize ) {cout<<”非法插入位置!\\n”; return 0;} for(j=L->n;j>=i;j--) L->data[j]=L->data[j-1]; //节点后移 L -> data[j] = x; //插入x L->n++; //修改表长 Return 1; //插入成功 } 6、直接选择排序的算法 void SelectSort( list R, int n ) { inti, j, k; for (i=1; i<=n-1;i++) { //n-1趟排序 k=1 ; for(j=i+1;j<=n,j++) //在当前无序区中找键值最小的记录R[k] if(R[j].key