题目详情
当前位置:首页 > 计算机考试 > 中级软件设计师
题目详情:
发布时间:2023-11-17 23:53:48

[单项选择]单向链表中往往含有一个头结点,该结点不存储数据元素,一般令链表的头指针指向该结点,而该结点指针域的值为第一个元素结点的指针。以下关于单链表头结点的叙述中,错误的是()。
A. 若在头结点中存入链表长度值,则求链表长度运算的时间复杂度为O(1)
B. 在链表的任何一个元素前后进行插入和删除操作可用一致的方式进行处理
C. 加入头结点后,代表链表的头指针不因为链表为空而改变
D. 加入头结点后,在链表中进行查找运算的时间复杂度为O(1)

更多"单向链表中往往含有一个头结点,该结点不存储数据元素,一般令链表的头指针"的相关试题:

[填空题] 假设某个不设头指针的无头结点单向循环链表的长度大于1,S为指向链表中某个结点的指针。算法f30的功能是,删除并返回链表中指针S所指结点的前驱。请在空缺处填入合适的内容,使其成为完整的算法。
typedef struct node{
DataType data;
struct node *next;
}*LinkList;
DataType f 30(LinkList s){
LinkList pre,p;
DataType e;
pre=s;
p=s—>next;
while( (1) ){
pre=p;
(2)
}
pre—>next= (3) ;
e=p—>data;
free(p);
return e;
} (1)
[填空题]以下函数creat用来建立一个带头结点的单向链表,新产生的结点总是插在链表的末尾。单向链表的头指针作为函数值返回。请填空。 #include <stdio.h> struct list { char dara; struct list *next; }; struct list *creat( ) { struct list *h,*p,*q; char ch; h= (struct list (*) malloc (sizeof (struct list)); ______; ch=getchar( ); while(ch!=’’) { p=(struct list*) malloc) sizeof (struct list)); p->data=ch; ______; q=p; ch=getchar( ); } p->next=’/0’; ______: }
[填空题]以下函数creat用来建立一个带头结点的单向链表,新产生的结点是插在链表头的
末尾。单向链表的头指针作为函数值返回。请填空。
# include<stdio.h>
struct list
char data;
struct list * next;

struct list * creat;
struct list * h,* p,* q;
char ch;
h=(______)malloc ( sizeof(struct list));
p=q=h;
ch=getchar( );
while(ch!=’’)
p=(______)mallco(sizeof(struct list));
p->data=ch;
q->next=p;
q=p;
ch=getchar( );

p->next=’/0’;
______;

[填空题]以下程序建立一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-1时,表示输入结束(键表头结点的data域不放数据,表空的条件是ph->next==NULL),请填空。
#include<stdio.h>
struct list int data;struct list*next;;
struct list*creatlist( )
struct list*p,*q,*ph;int a;ph=(struct list*)malloc(sizeof(struct list));
p=q=ph;printf("Input an integer number;entre-1 to end:/n");
scanf("%d",&a);
while(a!=-1)
p=(struct list*)malloc(sizeof(struct list));
【19】 =a;q->next=p; 【20】 =p;scanf("%d",&a);
p->next=’/0’;return(ph);
main( )
struct list * head;head=creatlist( );
[填空题]以下程序的功能是建立—个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-1时,表示输入结束(链表头结点的data域不放数据,表空的条件是ph->next==NULL),请填空。 #include<stdio.h> struct list { int data;struct list *next;}; struct list * creatlist( ) { struct list *p,*q,*ph;int a;ph=(struct list *)malloc(sizeof(struct list)); p=q=ph;printf("Input an integer number;entre-1 to end:/n"); scanf("%d",&a); while(a!=-1) { p=(struct list*)malloc(sizeof(struct list)); [14] =a;q->next=p; [15] =p;scanf("%d",&a);} p->next=’/0’;return(ph);} main( ) {stuct list * head;head=creatlist( );}
[填空题]以下程序中函数 fun 的功能是:构成一个如图所示的带头结点的单向链表,在结点 的数据域中放入了具有两个字符的字符串。函数 disp 的功能是显示输出该单向链表 中所有结点中的字符串。请填空完成函数 disp。 head ab cd ef /0 #include typedef struct node /*链表结点结构*/ { char sub[3]; struct node *next; }Node; Node fun(char s) /* 建立链表*/ { …… } void disp(Node *h) { Node *p; p=h->next; while(= _______ ) { printf("%s/n",p->sub);p= _______ ; } } main( ) { Node *hd; hd=fun( ); disp(hd);printf("/n"); }
[填空题]以下程序中函数fun的功能是:构成一个如图所示的带头结点的单向链表,在结点的数据域中放入了具有两个字符的字符串。函数disp的功能是显示输出该单链表中所有结点中的字符串。请填空完成函数 disp。 #include typedef struct node/*链表结点结构*/ {char sub[3]; struct node * next; }Node; Node fun(char S) /*建立链表*/ { ……} void disp(Node *h) {Node*P; P=h->next; while(【 】) {printf("%s\n",P->sub);P=【 】; } } main( ) {Node *hd; hd=fun( );disp(hd);prinff("\n"); }
[填空题]下面程序中函数creat用于建立一个带头结点的单向链表,新产生的结点总是插在链表的末尾,单向链表的头指针作为函数值返回。将程序补充完整。
#include<stdiao.h>
struct list
char data; struct list * next;;
struct list * creat( )

struct list *h,*p,*q; char ch;
h= 【18】 malloc(sizeof(struct list));
p=q=h;ch=getchar( );
while(ch!=’’)

p= 【19】 malloc(sizeof(struct list));
p->data=ch;q->next=p;q=p;ch=getchar( );

p->next=’/0’;
【20】

[填空题]请补充fun函数,该函数的功能是:将带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为:2、4、6、8、10,逆置后,从头至尾结点数据域依次为:10、8、6、4、2。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
[试题源程序]
#include <stdio.h>
#include <stdlib.h>
#define N 5
typedef Struct node
int data;
struct node *next;
NODE;
void fun(NODE *h)

NODE *p, *q, *r;
p= (1) ;
if ( (2) ) return;
q=P->next;
P->next=NULL;
while (q)

r=q->next;
q->next=p;
p=q;
q= (3) ;

h->next=p;

NODE *creatlis (int a[])

NODE *h, *p, *q; int i;
h= (NODE *)malloc(sizeof(NODE));
h>next=NULL:
for(i=0; i<N; i++)

q=(NODE *)malloc(sizeof(NODE));
q->data=a[i];
q->next=NULL;
if(h->next==NULL)
h->next=p=q;
else

p->next=q; p=q;


return h;

void ou list(NODE *h)

NODE *p;
p=h->next;
if(p==NU
[单项选择]以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转存到链表的各个结点中,请为下划线处选择正确的选项。
#include < stdlib. h >
stuct node
char data; struct node * next; ;
( ) CreatList(char * s)
struet node * h, * p, * q;
h = (struet node * ) ma]loc(sizeof(struct node) );
p=q=h;
while( * s! =’/0’)
p = ( struct node * ) ma]loc ( sizeof( struct node) );
p- >data= *s; q- >next=p; q=p;
s++;

p- > next =’/0’;
return h
main( )
char str[ ] = "link list";
struet node * head;
head = CreatList (str);
A. char *
B. struet node
C. struct node *
D. char

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码