由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 这道题是选A 吗?
相关主题
这道题怎么做的?不用暴力,这道题有没有优化解
C++ Q93 - Q95这道题有没有答案呀?
这道题好像有点难一道面试题
这道题咋做?[电话面试] Amazon First Round
来问一个关于smart pointer的弱问题又问几个c语言编程的题目
Find Peak Element这道题要考啥?菜鸟问个C++的pointer问题
这道题什么意识?谁给改一个线程安全的smarter pointer类
这道题,怎么做呀?怎么准备一些hardcore C++的interview
相关话题的讨论汇总
话题: element话题: list话题: last话题: delete话题: add
进入JobHunting版参与讨论
1 (共1页)
T********3
发帖数: 19
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啊?
C********e
发帖数: 492
2
答案错了把
liveramp online面试?
f***c
发帖数: 338
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.
h***k
发帖数: 161
4
A
1 (共1页)
进入JobHunting版参与讨论
相关主题
怎么准备一些hardcore C++的interview来问一个关于smart pointer的弱问题
问一道算法题Find Peak Element这道题要考啥?
两个面试题目讨论一下这道题什么意识?
问一个smart pointer的问题这道题,怎么做呀?
这道题怎么做的?不用暴力,这道题有没有优化解
C++ Q93 - Q95这道题有没有答案呀?
这道题好像有点难一道面试题
这道题咋做?[电话面试] Amazon First Round
相关话题的讨论汇总
话题: element话题: list话题: last话题: delete话题: add