avatar
这道题是选A 吗?# JobHunting - 待字闺中
T*3
1
where F is a pointer to the first element in the list and L is a pointer to
the last element
en the list. The time of which of the following operations depends on the
length of the
list?
(A) Delete the last element of the list.
(B) Delete de first element of the list.
(C) Add an element after the last element of the list.
(D) Add an element before the first element of the list.
(E) Intechange the first two elementsof the list.
为啥正确答案是C啊?
avatar
C*e
2
答案错了把
liveramp online面试?
avatar
f*c
3
http://www.cs.sfu.ca/~yonas/personal/Downloads/CS_GRE.pdf
Remember that after performing any operation, the structure of the list must
remain
intact; in other words F and L must point to the ¯rst and last elements
respectively.
Choice B needs only the operation F = F->next;
Choice C needs only the operations L->next = new node, L = new node;
Choice D needs only the operations new node->next = F, F = new node;
Choice E needs only the operations T=F, F=F->next, T->next=F->next, F->next=
T;
All these do not depend on the length of the list. The answer is therefore A
. Indeed
in order to delete the last element from the list, we need to ¯rst
locate the element
before the last (which can not be accessed from L). Thus we must parse all
the list
from the ¯rst till the element just before the last after which we can
delete the last
element and assign L to the one before.
avatar
h*k
4
A
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。