📄 cs3da.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>第三章 答案</title>
</head>
<body>
<p class="MsoPlainText" style="line-height: 150%">第三章<span lang="EN-US"><span style="mso-spacerun: yes">
</span>答案</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US"><span style="mso-spacerun:
yes"> </span>1.①物理存储位置<span style="mso-spacerun: yes">
</span>②链域的指针值</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">2.①O(1)<span style="mso-spacerun: yes">
</span>②O(n)<span style="mso-spacerun: yes"> </span></span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">3.①前趋<span style="mso-spacerun: yes">
</span>②后继<span style="mso-spacerun: yes"> </span></span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">4.①q->link</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">5.①p->link②s->data<span style="mso-spacerun: yes">
</span>③<span style="mso-spacerun: yes"> </span>t</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">6.①单链表<span style="mso-spacerun: yes">
</span>②双链表<span style="mso-spacerun: yes"> </span>⑧非循环链表④循环链表</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">7.①浪费<span style="mso-spacerun: yes">
</span>②上溢<span style="mso-spacerun: yes"> </span>⑧预先分配<span style="mso-spacerun: yes">
</span>④空间<span style="mso-spacerun: yes"> </span>⑤上溢</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">8.①顺序②链接</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">9.①使空表和非空表统一;算法处理一致。</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">10.①一定②不一定</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US"> <o:p>
</o:p>
</span></p>
<p class="MsoPlainText" style="line-height: 150%">二、选择题</p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US"><span style="mso-spacerun:
yes"> </span>1.C<span style="mso-spacerun: yes"> </span>2.A<span style="mso-spacerun: yes">
</span>3. B<span style="mso-spacerun: yes"> </span>4.D<span style="mso-spacerun: yes">
</span>5.A 6. D<span style="mso-spacerun: yes"> </span>7. D<span style="mso-spacerun: yes"> </span></span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US"> <o:p>
</o:p>
</span></p>
<p class="MsoPlainText" style="line-height: 150%">三、应用题</p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US">1、</span><span style="mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"">【解答】</span><span lang="EN-US" style="font-family:"Times New Roman";mso-bidi-font-family:"Courier New""><o:p>
</o:p>
</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""><span style="mso-tab-count:1">
</span><b style="mso-bidi-font-weight:normal">template <class Type> <o:p>
</o:p>
</b></span></p>
<p class="MsoPlainText" style="text-indent: 21.25pt; line-height: 150%"><i style="mso-bidi-font-style:normal"><span lang="EN-US" style="font-size:9.0pt;
mso-bidi-font-size:10.5pt;font-family:"Times New Roman";mso-bidi-font-family:
"Courier New"">ListNode </span></i><b style="mso-bidi-font-weight:normal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""><Type></span></b><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""> * <i style="mso-bidi-font-style:normal">List
</i><b style="mso-bidi-font-weight:normal"><Type> ::</b> <i style="mso-bidi-font-style:normal">GetANode</i>
( <b style="mso-bidi-font-weight:
normal">int</b> <i style="mso-bidi-font-style:normal">i</i> )<b style="mso-bidi-font-weight:normal">
{<o:p>
</o:p>
</b></span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""><span style="mso-tab-count:1">
</span>//</span><span style="font-size:9.0pt;mso-bidi-font-size:10.5pt;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"">取得单链表中第</span><i style="mso-bidi-font-style:
normal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;
font-family:"Times New Roman";mso-bidi-font-family:"Courier New"">i</span></i><span style="font-size:9.0pt;mso-bidi-font-size:10.5pt;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"">个结点地址</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New"">,<i style="mso-bidi-font-style:normal">
i</i></span><span style="font-size:9.0pt;mso-bidi-font-size:10.5pt;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"">从</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New"">0</span><span style="font-size:9.0pt;
mso-bidi-font-size:10.5pt;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"">开始计数</span><span lang="EN-US" style="font-size:9.0pt;
mso-bidi-font-size:10.5pt;font-family:"Times New Roman";mso-bidi-font-family:
"Courier New"">, <i style="mso-bidi-font-style:normal">i </i>< 0</span><span style="font-size:9.0pt;mso-bidi-font-size:10.5pt;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"">时返回指针</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New"">0, <i style="mso-bidi-font-style:normal">i</i>
= 0</span><span style="font-size:9.0pt;mso-bidi-font-size:10.5pt;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman"">时返回表头结点地址。</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""><o:p>
</o:p>
</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""><span style="mso-tab-count:2">
</span><b style="mso-bidi-font-weight:normal">if</b> ( <i style="mso-bidi-font-style:
normal">i</i> < 1 ) <b style="mso-bidi-font-weight:normal">return</b> <i style="mso-bidi-font-style:normal">NULL</i><b style="mso-bidi-font-weight:normal">;</b><o:p>
</o:p>
</span></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""><span style="mso-tab-count:2">
</span><i style="mso-bidi-font-style:normal">ListNode</i> <<b style="mso-bidi-font-weight:
normal">Type</b>> * <i style="mso-bidi-font-style:normal">p = first</i><b style="mso-bidi-font-weight:normal">;<span style="mso-spacerun: yes">
</span>int</b> <i style="mso-bidi-font-style:normal">k</i> = 0<b style="mso-bidi-font-weight:
normal">;<o:p>
</o:p>
</b></span></p>
<p class="MsoPlainText" style="line-height: 150%"><b style="mso-bidi-font-weight:
normal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;
font-family:"Times New Roman";mso-bidi-font-family:"Courier New""><span style="mso-tab-count:2">
</span>while</span></b><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""> ( <i style="mso-bidi-font-style:normal">p</i>
!= <i style="mso-bidi-font-style:normal">NULL</i> <b style="mso-bidi-font-weight:
normal">&&</b> <i style="mso-bidi-font-style:normal">k</i> < <i style="mso-bidi-font-style:normal">i
</i>) <b style="mso-bidi-font-weight:normal">{</b> <i style="mso-bidi-font-style:normal">p</i>
= <i style="mso-bidi-font-style:
normal">p</i></span><span style="font-size:9.0pt;mso-bidi-font-size:10.5pt;
mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"">→</span><i style="mso-bidi-font-style:normal"><span lang="EN-US" style="font-size:9.0pt;
mso-bidi-font-size:10.5pt;font-family:"Times New Roman";mso-bidi-font-family:
"Courier New"">link</span></i><b style="mso-bidi-font-weight:normal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New"">;</span></b><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""><span style="mso-spacerun: yes">
</span><i style="mso-bidi-font-style:normal">k</i>++<b style="mso-bidi-font-weight:normal">;
}<o:p>
</o:p>
</b></span></p>
<p class="MsoPlainText" style="line-height: 150%"><b style="mso-bidi-font-weight:
normal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;
font-family:"Times New Roman";mso-bidi-font-family:"Courier New""><span style="mso-tab-count:2">
</span>return</span></b><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;font-family:"Times New Roman";
mso-bidi-font-family:"Courier New""> <i style="mso-bidi-font-style:normal">p</i><b style="mso-bidi-font-weight:normal">;<o:p>
</o:p>
</b></span></p>
<p class="MsoPlainText" style="line-height: 150%"><b style="mso-bidi-font-weight:
normal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:10.5pt;
font-family:"Times New Roman";mso-bidi-font-family:"Courier New""><span style="mso-tab-count:1">
</span>}<o:p>
</o:p>
</span></b></p>
<p class="MsoPlainText" style="line-height: 150%"><span lang="EN-US"> <o:p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -