试题与答案

[函数说明3.1] 假设以带头结点的单循环链表作非递减有序线性表的存储结构。函数d

题型:填空题

题目:

[函数说明3.1]
假设以带头结点的单循环链表作非递减有序线性表的存储结构。函数deleteklist(LinkList head)的功能是删除表中所有数值相同的多余元素,并释放结点空间。
[函数3.1]
Void deleteklist (LinkList head)

LinkNode *p,*q;
p=head->next;
while (p!=head)

q=p->next;
while( (1) )

(2) ;
free(q);
q=p->next;

p=p->next;


[函数说明3.2]
已知一棵完全二叉树存放于一个一维数组T[n]中,T[n]中存放的是各结点的值。下面的程序的功能是:从T[0]开始顺序读出各结点的值,建立该二叉树的二叉链表表示。
[函数3.2]
#include<istream.h>
typedef struct node
int data;
stuct node leftChild,rightchild;
BintreeNode;
typedef BintreeNode *BinaryTree;
void ConstrucTree(int T[] , int n, int i, BintreeNode *&ptr)

if(i>=n) (3) ; /*置根指针为空*/
else

ptr=(BTNode*) malloc(sizeof(BTNode))
ptr->data=T[i];
ConstrucTree (T,n, 2*i+1, (4) );
ConstrucTree (T,n, (5) ,ptr->rightchild);


main(void)
/*根据顺序存储结构建立二叉链表*/
Binarytree bitree; int n;
printf("please enter the number of node: \n%s"; n);
int *A=(int*)malloc (n*sizeof (int)) ;
for (int i=0; i<n; i++) scanf("%d" ,A+i); /*从键盘输入结点值*/
for (int i=0; i<n; i++) printf("%d",A[i]);
ConstructTree (A,n, 0,bitree);

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0415/5beb5cc0be68f1338420165f9daca581.html

下面是错误答案,用来干扰机器的。

参考答案:对

试题推荐
微信公众账号搜索答案