# 資料結構與演算法第五版(高立512326)勘誤
| 徐熊健 <br> 上次更新日期:Nov. 2024, Aug. 2024, July 2024, Feb. 2024, <br>Sep. 2023; 2023, 7, 22/ <br> 2023, 2, 19/2023, 2, 9, (2023/1/26 前者已更正) <br><br> 若有其他發現,請利用留言功能(頁面右上角圖示) 留下更正或建議,謝謝! |  |
|--|--|
| $頁數$ |行數/區段| 錯誤 | 更正 |
| --- | --- | -------- |--|
| 1-33 | 頁末最後<br>一段落 |  | |
| 2-24 | 經驗法則<br>2-7騎士<br>巡迴問題 |5$\qquad\qquad$for (0 $\le$ k $\le$ <font color="#f00">n-1</font>) | 5$\qquad\qquad$for (0 $\le$ k $\le$ <font color="#08f">7</font>)|
| 2-24 | 經驗法則<br>2-7騎士<br>巡迴問題 |15$\qquad\qquad$for (0 $\le$ k $\le$ <font color="#f00">n-1</font>) | 15$\qquad\qquad$for (0 $\le$ k $\le$ <font color="#08f">7</font>)|
|3-18 | 7 | CQueue[<font color="#f00">(front+1)</font>%maxsize]方為環狀佇列 | CQueue[<font color="#08f">++front</font>%maxsize]方為環狀佇列 |
|3-18 | 8 | CQueue[<font color="#f00">rear</font>%maxsize]則為環狀佇列 | CQueue[<font color="#08f">++rear</font>%maxsize]則為環狀佇列 |
| 3-28 | -6 | 重<font color="#f00">覆</font>再試已走過的步伐 | 重<font color="#08f">複</font>再試已走過的步伐|
| 4-24 |程式4-6 <br> 修正紅框<br>內容成為<br>藍框者 |  |  |
|4-44 | -1 | 以重<font color="#f00">覆</font>呼叫 | 以重<font color="#08f">複</font>呼叫 |
|5-100|程式5-26| 88 $\qquad$ { temp = InorderAVLSucc(node<font color="#f00">->rightchild</font>); | 88 $\qquad$ { temp = InorderAVLSucc(node); |
| 6-8 | -3 | 相同的邊不得重<font color="#f00">覆</font> | 相同的邊不得重<font color="#08f">複</font> |
| 7-19 | 演算法7-6 | 輸入:<font color="#f00">data</font>陣列<br>輸出:排序陣列<font color="#f00">data</font>...<font color="#f00">data</font>[i]$\le$<font color="#f00">data</font>[j] | 輸入:<font color="#08f">data</font>陣列<br>輸出:排序陣列<font color="#08f">data</font>...<font color="#08f">data</font>[i]$\le$<font color="#08f">data</font>[j] |
## 資料結構與演算法第四版(高立512326)勘誤
| 徐熊健 <br> 上次更新日期:Aug. 2024, July 2024, Feb. 2024, <br>Sep. 2023; 2023, 7, 22/ <br> 2023, 2, 19/2023, 2, 9, (2023/1/26 前者已更正) <br><br> 若有其他發現,請利用留言功能(頁面右上角圖示) 留下更正或建議,謝謝! |  |
|--|--|
| $頁數$ |行數/區段| 錯誤 | 更正 |
| --- | --- | -------- |--|
| 2-3 | 程式2-2 下第3行 | 迴圈變數 i(i=<font color="#f00">0,1,2,3,4</font>)加1亦即<font color="#f00">1,2,3,4,5</font>; | 迴圈變數 i(i=<font color="#08f">0、1、2、3、4</font>)加1亦即<font color="#08f">$\ 1、2、3、4、5$</font> <br>(註:(1) 紅色"<font color="#f00">0,1,2,3,4</font>" 字體 courier new 不變,且逗號改為頓號!<br>(2) 紅色"<font color="#f00">1,2,3,4,5</font>" 字體由 courier new 改為 Times New Roman,且逗號改為頓號!)|
| 2-14 | 2 | 宣告矩陣 <font color="#f00">$A$</font> 如下: | 宣告矩陣 <font color="#f00">A</font> 如下:(註:"A" 不須斜體,字體為 courier new。)|
| 2-15 | 範例2-7 | 則<br>$\qquad$ <font color="#f00">*C* = </font> |則<br>$\qquad$<font color="#08f">$C=A+B=$ </font> <br>註:"*C* =" 改為 "*C* = A+B ="(字體為 Times New Roman)。|
| 2-18 | 演算法2-6 行號6 |  | 紅框中的空格請刪去。|
| 2-24 |經驗法則 2-7行號2 | 2$\quad$K[x][y]=1;$\quad$//<font color="#f00">讀入起始點</font> | 2$\quad$K[x][y]=1;$\quad$//<font color="#08f">設定起始點</font> |
| 2-24 |經驗法則 2-7行號4 |  | 行號4"//"請請加空格<br>使與行號2的"//"對齊。 |
| 2-24 |經驗法則 2-7 |  | 註:(1) 紅框、橘框中的 n 皆改為 n-1;(2)橘框內的文字請改為<br>"(0$\le$tx$\le$n-1 && 0$\le$ty$\le$n-1)" (刪去"$\le$"前後的空格,以防此行<br>佔兩行。) |
| 2-27 | 2 | 可描繪如圖 2-13<font color="#f00">。</font>其中... | 可描繪如圖 2-13<font color="#08f">;</font>其中... |
| 4-12 | 圖4-7 |  | 將紅框中的 "[s1]" 刪去。 |;
| 4-12 | 9 | 將 x->next 改為 <font color="#f00">q(原來的 p->next)</font> | 將 x->next 改為 <font color="#08f">p->next</font>|;
|4-49 | 3 | 的精髓(<font color="#f00">矩陣</font>中... | 的精髓(<font color="#08f">此處矩陣</font>中... |
| 6-13 | 圖6-13 |  | 紅框內 "C2" 文字請刪除。|
| 6-40 | 演算法 6-7,輸入 | 輸入:... 相鄰矩陣<br><font color="#f00">或相鄰串列</font> *E* | 輸入:... 相鄰矩陣 *E* <br>(註:刪去"<font color="#f00">或相鄰串列</font>"。) |
| 6-53 | 演算法 6-8,輸入 | 輸入:... 相鄰矩陣<br><font color="#f00">或相鄰串列</font> *E* | 輸入:... 相鄰矩陣 *E* <br>(註:刪去"<font color="#f00">或相鄰串列</font>"。) |
| 6-57 | 本頁第二段<br>與演算法6-9 | 本頁第二段與演算法6-9多處重新描述與改寫! | 請見附檔 06_p6-57.doc;其中更新處標記藍色,並有進行排版;更新前後皆為p.6-57,頁數不變<br>(可見06_p6-57.pdf)。可以直接複製檔案06_p6-57.doc<br>的藍色文句後貼入成果檔中! |
|6-59 |演算法6-10 | |(1) "起點" 該行請向左對齊;<br>(2)行號4 "r" 前請加空格使與上 "(" 對齊。 |
| 7-31 | 演算法<br> 7-10|  | 行號10的左側請與藍色虛線對齊。 |
| 7-32 | 5 | 數字 i 在<font color="#f00">排列</font>後的排位(或排序<font color="#f00">陣列</font>中的註標) | 數字 i 在<font color="#08f">排序</font>後的排位(或排序<font color="#08f">陣列B</font>中的註標)<br> (註:"B"字體為 Courier new)|
|7-33 | 1-3 | | 紅框內字體應為 Courier new;無標記者請維持原樣。(亦可參考之前寄出的 07_sjshyu.doc)|
| 7-33 | 4-6 |  | 紅框內字體應為 Courier new;無標記者請維持原樣。(亦可參考之前寄出的 07_sjshyu.doc)|
| $頁數$ |行數/區段| 錯誤 | 更正 |
| --- | --- | -------- |--|
| 1-13 |註脚6<br>行1 | 即<font color="#f00"> 調</font>程式碼應同時 | 即<font color="#08f">强調</font>程式碼應同時 (註:"<font color="#08f">强</font>"因字體關係<br>未能正確顯示,可以換字體、亦可用"<font color="#08f">強</font>")|
| 2-3 | 程式2-2 下第3行 | 迴圈變數 i(i=<font color="#f00">0,1,2,3,4</font>)加1亦即<font color="#f00">1,2,3,4,5</font>; | 迴圈變數 i(i=<font color="#08f">0、1、2、3、4</font>)加1亦即<font color="#08f">$\ 1、2、3、4、5$</font> <br>(註:(1) 紅色"<font color="#f00">0,1,2,3,4</font>" 字體 courier new 不變,且逗號改為頓號!<br>(2) 紅色"<font color="#f00">1,2,3,4,5</font>" 字體由 courier new 改為 Times New Roman,且逗號改為頓號!)|
| 2-9 | 7(範例2-4下1行) | 資料:<font color="#f00">9、8、4、7、2、3</font>,... | 資料:<font color="#08f">$9、8、4、7、2、3$</font>,... <br>(註:字體由 courier new 改為 Times New Roman,頓號不變。)|
| 2-14 | 4 |  | (1) 紅框一內斜體A改為不斜體,字體由 Times New Roman courier new 改為 courier new; (2) 紅框二內斜體A、i、j 字型改為標準(不斜體),字體依然為 courier new。|
| 2-15 | 範例2-7 | <font color="#f00">*C*</font> |<font color="#08f">*C* = </font><font color="#08f"> = </font><br>註:(1) 紅框一"*C*" 改為 "*C* = "(字體依舊為 Times New Roman);<br>(2) 紅框二中"="請往右移(大約兩~三格)。|
| 2-16 | 7 |  |<br>註:請將"n-1"中的"-",改為其前 "m-1"中的"-" (字體為 Symbol)。|
| 2-17 |演算法2-5行號1 |  | 註:紅框中的 j, j(下標), i, i(下標) 分別改為 <font color="#08f"> k, k(下標), k, k(下標)</font>。 |
| 2-19 |程式2-5<br>行號7 | // cerr$\quad$<font color="#f00"> 調</font>錯誤訊<br>息的輸出,作用與 cout 同 | // cerr <font color="#08f">强調</font>錯誤訊<br>息的輸出,作用與 cout 同 <br>(註:"<font color="#08f">强</font>"因字體關係未能正確顯示,可以換字體、亦可用"<font color="#08f">強</font>")|
| 2-19 |程式2-5<br>行號9,10 |  | 註:紅框中的 "," 請改為 "<font color="#08f">;</font>" 。 |
| 2-24 |經驗法則2-7 |  | 註:(1) 紅框中的 7 皆改為 n;(2)紫框內的文字請刪去。 |
| 2-24 |經驗法則2-7 |  | 註:紅框中的 7 皆改為 n。 |
| 2-27 | 2 | 在記憶體中的配置<font color="#f00">位置</font>,... | 在記憶體中的配置<font color="#08f">空間A</font>,... <br>(註:A的字體為 Courier new。)|
| 2-27 | 3 | 憶體<font color="#f00">中</font>的位址為 | 憶體<font color="#08f">A[i]中</font>的位址為 <br>(註:"<font color="#08f">A[i]</font>"的字體為 Courier new。)|
| 2-27 | -7 | ...組(16 <font color="#f00">位元</font>佔 2 個位元組)| ...組(16 <font color="#08f">位元電腦僅</font>佔 2 個位元組) <br>(註:加入"<font color="#08f">電腦僅</font>"三字。)|
| 3-30 | 演算法3-1 | 輸入:迷宮<font color="#f00">,</font>以二維陣列...出口在<font color="#f00">(m,p)。</font> | 輸入:迷宮<font color="#08f">—</font>以二維陣列...出口在<font color="#08f">(m,p)</font> <br>(註:(1)逗號改為破折號;(2) 省略句號。)|
| 3-33 | 程式3-15 | 39$\quad$</font>輸出:”此迷宮無出路” | 39$\quad$<font color="#08f">//</font>輸出:”此迷宮無出路”<br> (註:加入"//"。) |
| 3-33 | 2 | 第 <font color="#f00">20</font> 行用了 d<=NW | 第 <font color="#08f">21</font> 行用了 d<=NW |
| 3-33 | 4 | 第 <font color="#f00">25</font> 行的 step.dir=d+1 | 第 <font color="#08f">26</font> 行的 step.dir=d+1 |
| 3-33 | 5 | (之後 <font color="#f00">18~19</font> 行 pop 出 | (之後 <font color="#08f">19~20</font> 行 pop 出|
| 3-33 |6 | —在第 <font color="#f00">28~29</font> 行中輸出 | —在第 <font color="#08f">29~30</font> 行中輸出 |
| 3-33 | 8 | 第 <font color="#f00">2</font> 行中堆疊的大小<font color="#f00">宣告為$m×p$</font>,這...的上限值<font color="#f00">,這是把</font>直覺 | 第 <font color="#08f">2、13</font> 行中堆疊的大小<font color="#08f">動態宣告為$m×p$ (使用後於31或40行回收)</font>,這...的上限值<font color="#08f">—將</font>直覺 |
| 3-33 | 10 | 的上限值。<font color="#f00">堆疊使用的實際<br>最差狀況</font>可... | 的上限值。<font color="#08f">實際上堆疊使用的<br>最佳和最差狀況</font>可... |
| 3-37 | 5 | 選用包含二維陣列的 <font color="#f00">x-y</font> | 選用包含二維陣列的 <font color="#08f">x-y</font><br>(字體由 Times New Roman 改為 Courier new ) |
| 3-38 | 1 | 第 <font color="#f00">6</font> 行判斷 | 第 <font color="#08f">6</font> 行判斷 <br>(字體由 Times New Roman 改為 Courier new )|
| 3-38 | -1 |並改寫第 <font color="#f00">6</font> 為 | 並改寫第 <font color="#08f">6</font> 為 <br>(字體由 Times New Roman 改為 Courier new )|
| 3-46 | 3 | 識別字元 # 且令 q(#)...—此 <font color="#f00">#</font> 可使第 | 識別字元 # 且令 q(#)...—此 <font color="#08f">#</font> 可使第 <br>(字體由 Times New Roman 改為 Courier new ;與前者"#"相同。)|
| 4-13 |程式4-3<br>下一行 | 有了程式 <font color="#f00">4-3</font> 的定義| 有了程式 <font color="#08f">$4-3$</font> 的定義<br>(字體由 Courier new 改為 Times New Roman。)|
| 4-14 | 程式4-4<br>前兩行 | $\quad$<font color="#f00">請留意</font>...下面的程序<br>可完成這<font color="#f00">個</font>需求。 | <font color="#08f">請留意</font> ... 下面的程序可完成<br>這<font color="#08f">些檢測與</font>需求。<br>(註:此段與上段為同一段,不必因跳行而縮排。)|
| 4-19 | 行-3 | 更新 first 為<font color="#f00">原最後節點,</font> | 更新 first 為<font color="#08f">最後節點s</font>,<br>(註:(1)刪除"原";(2)加入"s",字體為Courier new。) |
|4-47 | -7~-6 | <font color="#f00">而本節介紹</font>二維串列的架構來<br>存放<font color="#f00">,這些非 0 值對</font>二維矩<br>陣的運算(如:矩陣相加、相乘)<font color="#f00">大抵會比較</font>方便。 | <font color="#08f">在此介紹以</font>二維串列的架構來<br>存放<font color="#08f">稀疏矩陣,既有節省空間<br>的好處,</font>對二維矩陣的<br>運算(如:矩陣相加、相乘)<font color="#08f">也比用一維串列更為直覺與</font>方便。|
|4-48 | 2-3 | ...如此繪製僅為方便後續<br>畫出稀疏矩陣如圖4-32<font color="#f00">,但各指標欄位實體空間的<br>大小是相同的!</font> | ...如此繪製僅為方便後續<br>畫出稀疏矩陣如圖4-32<font color="#08f">。</font> <br> (註:紅色文字刪除、句末有句號。)|
|4-48 | 4 | 圖 4-32 描繪了一個<br><font color="#f00">稀疏矩陣與其對應串列的</font>範例 | 圖 4-32 描繪了一個<br><font color="#08f">以二維串列表示稀疏矩陣的</font>範例 |
|4-48 | 6 | (1) <font color="#f00">矩陣</font>的開頭空白節點 | (1) <font color="#08f">二維串列</font>的開頭空白節點 |
|4-48 | -1 | 指向<font color="#f00">矩陣</font>的開頭空白節點<font color="#f00">。</font> | 指向<font color="#08f">稀疏矩陣</font>的開頭空白節點<font color="#08f">。對一個 $m\times n$ 含有 $k$ 個非 $0$ 元素的稀疏矩陣而言,以二維陣列<br>儲存的空間需求為 $O(mn)$,而以二維串列存放則為<br> $O(n+m+k)$。</font><br> (註:段尾加入藍色文字,變數字體為 Times New Roman。)|
|4-49 | 1-2 | <font color="#f00">串列、稀疏矩陣、甚至於是稀疏多維矩陣、…等結構,都有節省空間的優點,讀者宜掌握儲存必要資料的精髓(非必要者毋須儲存);</font>至於其輸入... | <font color="#08f">稀疏矩陣(二維、甚至於是多維),<br>可用串列(二維、或多維)存放,以收節省空間之效;讀者宜掌握<br>儲存必要資料於串列節點中的精髓(矩陣中的元素 0 即為非必要者)。</font>至於其輸入...|
|4-49 | 圖4-32 標題 | <font color="#f00">稀疏矩陣</font>的例子 | <font color="#08f">以二維串列表示稀疏矩陣</font>的例子 |
| 5-6 |註脚3<br>行3 | 無根樹較為<font color="#f00"> 調</font>點之<br>間的連結關係 | 無根樹較為<font color="#08f">强調</font>點之<br>間的連結關係 <br>(註:"<font color="#08f">强</font>"因字體關係未能正確顯示,可以換字體、亦可用"<font color="#08f">強</font>")|
| 5-6 |註脚4<br>行1 | ...習慣的畫法<font color="#f00">,</font>當然... | ...習慣的畫法<font color="#08f">;</font>當然...<br>(註:逗號改為句號)|
|5-88 | -2 | - height(<font color="#f00">x</font>->rightchild); |- height(<font color="#08f">p</font>->rightchild); |
|5-89 | 程式5-23 |  |紅框中的空格請刪除 |
|5-106 | 演算法5-2 |  | (1)刪除行號5下一行的句號(紅雙刪除線);<br>(2)加入藍色文字於行號6的下一行:<br>|
|5-107 | 圖5-56 | 圖5-56(a)、(b)品質不佳 | 請參用05-p106-p107.doc 的圖5-56(a)、(b);輸出如~.pdf。兩圖的相對大小可參考之。|
| 6-59 | 演算法<br> 6-10| 輸入:... 演算法<br>6-8或6-9所得出的<br>頂點連接<font color="#f00">矩陣</font> *C* | 輸入:... 演算法6-8<br>或6-9所得出的頂點<br>連接<font color="#08f">陣列</font> *C* |
| 6-83 | -3 | .count 則記錄了 <font color="#f00">i</font> 所有直接 | .count 則記錄了 <font color="#08f">頂點 i</font> 所有直接|
| 7-12 | 演算法<br> 7-3|  | 行號6紅框處共兩個空格,請取代為一個空格。 |
| 7-12 | 演算法<br> 7-3|  | 行號7、8紅框處請各多加入二個<br>空格(比照行號4)。 |
| 7-30~<br>7-34 | 7.2.7<br>計數排序法 | 本小節多處重新描述;含新增、刪除、改寫字句、加入演算法7-10的諸多程式註解! | 請見附檔 07_sjshyu.doc;其中更新處標記藍色,並有進行排版;更新前後皆為7-30~7-34,頁數不變(可見07-30_34.pdf)。可以直接複製檔案的 p.7-30~p.7-34 後貼入成果檔中! |
以下僅供參考。
| $頁數$ |行數/區段| 錯誤 | 更正 |
| --- | --- | -------- |--|
| 7-30 | 5 | 小到大的排序數列中應排在第 31(或 32,如果<font color="#f00">有</font> 2 個 11)個位置。|小到大的排序數列中應排在第 31(或 32,如果<font color="#08f">它是第</font> 2 個 11)個位置。 |
| 7-30 |9-10 | 7 的排<font color="#f00">名</font>位置為 <font color="#f00">1~2</font>、8 的排位應為 <font color="#f00">3~5</font>、而 9 則為 <font color="#f00">6</font>|小到大的排序數列中應排在第 31(或 32,如果<font color="#08f">它是第</font> 2 個 11)個位置。 |
| 7-31 | 演算法<br> 7-10|  | 行號10的左側請與藍色虛線對齊。 |
| 7-32 | 範例7-8下一行|...後的結果<font color="#f00">-</font>前綴和後 | 後的結果<font color="#08f">—</font>前綴和後 <br>請改成破折號!|
| 7-32 | 範例<br> 7-8| | 紅框內的 9 9 9 10 請改成藍框內的 10 10 10 11。 |
| 7-33 | 範例<br> 7-8| | 紅框內的 9 9 9 10 請改成如上藍框內的 10 10 10 11。 |
下面的程序
### 2024/07/21 以前
| $頁數$ |行數/區段| 錯誤 | 更正 |
| --- | --- | -------- |--|
| 1-18 | 程式1-5 |  | |
| 2-4 |程式2-2 標題 | ... 對應元素相<font color="#f00">加</font> | ... 對應元素相<font color="#08f">乘</font> |
| 2-19 |程式2-5 | 6$\quad$ ... $\quad$ "輸入方<font color="#f00">塊</font>過大或小... | 6$\quad$ ... $\quad$ "輸入方<font color="#08f">陣</font>過大或小... |
| 2-19 |程式2-5 | 8$\quad$ ... $\quad$ "輸入方<font color="#f00">塊</font>邊長... | 6$\quad$ ... $\quad$ "輸入方<font color="#08f">陣</font>邊長... |
| 2-24 |經驗法則2-7 | 輸出: ... 以 1~<font color="#f00">64</font>的編號 | 輸出: ... 以 1~<font color="#08f">n*n</font>的編號 |
| 2-24 |經驗法則2-7 | 23$\quad${$\quad$if (next_<font color="#f00">moves</font>[t] < next_<font color="#f00">moves</font>[min]) | 23$\quad${$\quad$if (next_<font color="#08f">move</font>[t] < next_<font color="#08f">move</font>[min]) |
| 2-25 |8 | ... 令其為 next_<font color="#f00">moves</font>[min]) | ... 令其為 next_<font color="#08f">move</font>[min]) |
| 2-27 | 1 | ... 的起<font color="#f00">點</font>為 $\alpha$ | ... 的起<font color="#08f">始位址</font>為 $\alpha$ |
| 2-31 |圖2-18 $\text{(c)}$| |  |
| 3-5 | 範例3-3下一行 | ...的例子 | ...的例子<font color="#08f">,如圖3-3。</font> |
| 3-5 | 圖3-3(a) |  | <font color="#08f">請刪去紅框中的Label1</font> |
| 3-5 | 圖3-3(b) |  |  |
| 3-30 | 演算法3-1 | 輸入:...表示<font color="#f00">。<font> | 輸入:...表示<font color="#08f">,大小為 m*p;入口在 (1, 1)、出口在 (m, p)</font> |
| 3-30 | 演算法3-1 | 輸出:...的<font color="#f00">路徑。<font> | 輸出:...的<font color="#08f">路徑</font> (省略"。")|
| 3-32 | 程式3-15 | 2 $\quad$ struct position <font color="#f00">Stack[m*p]<font>; | 2 $\quad$ struct position <font color="#08f">* Stack</font>; |
| 3-32 | 程式3-15 | 12$\quad${$\quad$ struct position step; | 12$\quad${$\quad$ struct position step; <font color="#08f"><br>13$\quad \quad$ Stack = new struct position [m*p]; </font> <br> (註:12行s~ 與 13行S~ 請對齊) |
| 3-32 | 程式3-15 | 行號 <font color="#f00">13-29</font> | 行號 <font color="#08f">14-30</font> |
| 3-32 | 程式3-15 | <font color="#f00">30</font>$\quad\quad$return; | <font color="#08f">31$\quad\quad$delete [] Stack; <br> 32</font>$\quad\quad$return; |
| 3-32 | 程式3-15 | 行號 <font color="#f00">31-37</font> | 行號 <font color="#08f">33-39</font> |
| 3-32 | 程式3-15 | <font color="#f00">37$\quad\quad$//</font>輸出:”此迷宮無出路”<br> <font color="#f00">38$\;\;$} | <font color="#08f">39</font>$\quad\quad$輸出:”此迷宮無出路”<font color="#08f">;<br> 40 $\ \ \quad$ delete [] Stack;<br> 41 $\;\;$}</font> |
| 3-51 | 演算法3-5 |22 $\quad$while (x=pop() != “#”) <font color="#f00">output(x);</font> | 22 $\quad$while (x=pop() != “#”) <font color="#08f"> push_opn(get_prefix(x)); |
| 4-12 | -4~-2 |  | ...包括 3 個鏈結的異動。事實上 (2) 和 (3) 可同時完成(如程式 4-3 所示)。我們還得考慮 p 為 NULL 的情形,<font color="#08f">亦即整個串列是空的(程式中 p->next 在 p 是 NULL 時會中斷執行)!</font> 此時 ... <br>(註:此兩段請合併,加入"<font color="#08f">亦即整個...中斷執行)!</font>"程式碼字體是 courier new。)|
| 4-14 | 程式4-4前一行 | 下面的程序... | <font color="#08f">請留意 p 甚至於 p->next 有可能是 NULL 的情形!</font> 下面的程序... <br>(註:程式碼字體是 courier new。)|
| 4-19 | 行-7 | s->link 應為 <font color="#f00">NULL</font>(它本是...最後節點),此時 <font color="#f00">r</font> 應為 | s->link 應為 <font color="#08f">NULL</font>(它本是...最後節點),此時 <font color="#08f">t</font> 應為 <br>(註:<font color="#08f">NULL/t</font> 字體皆是 courier new。)|
| 4-19 | 行-4 | 由圖 <font color="#f00">14</font> \(c)-(e) 可知 ... 順勢平移(見圖 <font color="#f00">14</font> (f)) | 由圖 <font color="#08f">14-11</font> \(c)-(e) 可知 ... 順勢平移(見圖 <font color="#08f">14-11</font> (f))|
| 4-19 | 行-3 | s-link,各節點... | s-link<font color="#08f"> (設之為t)</font>,各節點... <br>(註:<font color="#08f">(、)</font> 是全形括號、 <font color="#08f">t</font> 字體是 courier new。)|
| 4-21 | 行1 | t、s、r 的處理<font color="#f00">,</font> | t、s、r 的處理<font color="#08f">(見圖4-11 (f)),</font><br>(註:外層括號<font color="#08f">(、)</font> 是全形、"(f)" 則是半形。)|
| 4-21 | 行2 | (s->link = t;)<font color="#f00">;</font> | (s->link = t;)<font color="#08f">(見圖 \(c));</font><br>(註:外層括號<font color="#08f">(、)</font> 是全形、"\(c)" 則是半形。)|
| 4-21 | 行3 | 屆時 r 必為 NULL<font color="#f00">!</font> | 屆時 r 必為 NULL<font color="#08f">(見圖 (e));</font><br>(註:外層括號<font color="#08f">(、)</font> 是全形、"(e)" 則是半形。)|
| 4-21 | 行3 | 初始化指標 r、s <font color="#f00">(見圖11 (f))</font> | 初始化指標 r、s <br>(註:刪除之)|
| 4-21 | 行4 | ... 態(比較圖 <font color="#f00">11</font> (d)、(f)) | ... 態(比較圖 (d)、(f)) <br>(註:刪除之)|
| 4-23 | 程式 4-10,行號17 | 17$\qquad$if (top == NULL) top = x; | 17$\qquad$if (top == NULL) top = x;$\qquad$<font color="#08f">// 17、18行非必要,可省略;解釋於後</font><br>(註:加在行末)|
| 4-40 | 程式4-18 | 37$\quad$while (p!=head_a &&<font color="#f00"> p</font>!=head_b)| 37$\quad$while (p!=head_a &&<font color="#08f"> q</font>!=head_b)|
| 4-41 | 註腳19,行2-3 | $\quad$<br><font color="#f00">$\quad$x</font> = NewTerm(coef, expo); <br>InsertLast(x, last_a);| <br><font color="#08f">x</font> = NewTerm(coef, expo); <br>InsertLast(x, last_a); <br>(註:此兩行左緣對齊)|
| 4-44 | 7-8 | A(x) = <font color="#f00">-4</font>x²+1<br>B(x) = <font color="#f00">4</font>x³<font color="#f00">-9</font>x²+2x-3 | A(x) = <font color="#08f">3</font>x²+1<br>B(x) = <font color="#08f">6</font>x³<font color="#08f">+9</font>x²+2x-3 |
| 4-44 | 圖4-30 |  | |
|4-48 | 1-2 | 並不完全相同<font color="#f00">(如此繪製<br>僅為方便後續畫出<br>稀疏矩陣如圖4-32),但各指標欄位實體<br>空間的大小是相同的!</font> | 並不完全相同<font color="#08f"><br>(例如:<br>row和col是整數、value可能是整數<br>或其它、down和<br>right則是節點指標),如此繪製僅為方便<br>後續畫出稀疏矩陣<br>如圖4-32。</font>[註:<br>上列 row, col, value, <br>down 和 right 的字型<br>請用 courier new] |
|4-66 | 第5題,行-1 | $x_n, y_n, y_{n+1},$ <font color="#f00"><br>$x$</font>$_{n+2}, ... ,y_m$ | $x_n, y_n, y_{n+1},$ <font color="#08f"><br>$y$</font>$_{n+2}, ... ,y_m$ |
|5-88 | 程式5-2,行8 | AVLRoot | AVLRoot<font color="#08f">;</font> |
| 6-11 | 行6 | 除了起點和終點可能<br>相同外,其它的頂點<br>皆不同的路徑。 | 除了起點和終點可能相同<font color="#08f">(該點走訪恰兩次)</font>外,其它的頂點皆不同<font color="#08f">(走訪僅一次)</font>的路徑。 |
| 6-52 | 行-1 | ...即可得解。 | ...即可得解。<font color="#08f">為求出最短路徑,可加入「頂點連接陣列」*C*,容後解釋。</font> |
| 6-53 | 演算法 6-8,輸出 | 輸出:*G* 中 *u* 到 *v* 的最短距離,*v*∈*V*,*v*≠*u* | 輸出:*G* 中 *u* 到 *v* 的最短距離<font color="#08f">*D*[*v*]</font>,*v*∈*V*,*v*≠*u*<font color="#08f">;頂點連接陣列*C*</font> |
| 6-53 | 演算法 6-8,輸出、行1-5 | | 
|
| 6-57 | 行8 | <font color="#f00">倘若</font>用空間 *O*(*n*+*e*) 的相鄰串列 | <font color="#08f">亦可</font>用空間 *O*(*n*+*e*) 的相鄰串列 |
| 6-57 | 演算法 6-9,輸入 | 輸入:...,相鄰<font color="#f00">串列</font>*E*,... | 輸入:...,相鄰<font color="#08f">串列或矩陣</font>*E*, |
| 6-57 | 演算法 6-9,輸出 | 輸出:*u* 到 *v* 的最短距離,*v*∈*V*,*v*≠*u* | 輸出:<font color="#08f">*G* 中 </font> *u* 到 *v* 的最短距離<font color="#08f">*D*[*v*]</font>,*v*∈*V*,*v*≠*u*<font color="#08f">;頂點連接陣列*C*</font> |
| 6-59 | 演算法 6-10,輸入第2行 | 輸入:... 演算法6-8所得出的頂點<br>連接<font color="#f00">矩陣</font> *C* | 輸入:... 演算法6-8<br><font color="#08f">或6-9 </font>所得出的頂點<br>連接<font color="#08f">陣列</font> *C* |
| 6-59 | 演算法 6-10,行號2 | // *toString*(*v*) 將 *v* 轉成字元資料型態 | // *toString*(*v*) 將<font color="#08f">整數</font><br> *v* 轉成字元資料型態 |
|6-67 | 圖 6-41 |  |  <br>註:去除分隔垂直線 |
|6-83 | 程式6-5 行號65、66 |  |  <br>註:65行 "p->"之前加一空格,使與65行向左對齊 |
| 7-52 | 第7題 | (b) 用<font color="#f00">鍵</font>結串列實作最小(大)堆積 | (b) 用<font color="#08f">鏈</font>結串列實作最小(大)堆積 |
# -- 以下皆為備份資訊 --
## 第四版 (2023/9 後)
| $頁數$ |行數/區段| 錯誤 | 更正 |
| --- | --- | -------- |--|
| 1-18 | 程式1-5 |  | |
| 2-4 |程式2-2 標題 | ... 對應元素相<font color="#f00">加</font> | ... 對應元素相<font color="#08f">乘</font> |
| 2-19 |程式2-5 | 6$\quad$ ... $\quad$ "輸入方<font color="#f00">塊</font>過大或小... | 6$\quad$ ... $\quad$ "輸入方<font color="#08f">陣</font>過大或小... |
| 2-19 |程式2-5 | 8$\quad$ ... $\quad$ "輸入方<font color="#f00">塊</font>邊長... | 6$\quad$ ... $\quad$ "輸入方<font color="#08f">陣</font>邊長... |
| 2-24 |經驗法則2-7 | 輸出: ... 以 1~<font color="#f00">64</font>的編號 | 輸出: ... 以 1~<font color="#08f">n*n</font>的編號 |
| 2-24 |經驗法則2-7 | 23$\quad${$\quad$if (next_<font color="#f00">moves</font>[t] < next_<font color="#f00">moves</font>[min]) | 23$\quad${$\quad$if (next_<font color="#08f">move</font>[t] < next_<font color="#08f">move</font>[min]) |
| 2-25 |8 | ... 令其為 next_<font color="#f00">moves</font>[min]) | ... 令其為 next_<font color="#08f">move</font>[min]) |
| 2-27 | 1 | ... 的起<font color="#f00">點</font>為 $\alpha$ | ... 的起<font color="#08f">始位址</font>為 $\alpha$ |
| 2-31 |圖2-18 $\text{(c)}$| |  |
| 3-5 | 範例3-3下一行 | ...的例子 | ...的例子<font color="#08f">,如圖3-3。</font> |
| 3-5 | 圖3-3(a) |  | <font color="#08f">請刪去紅框中的Label1</font> |
| 3-5 | 圖3-3(b) |  |  |
| 3-30 | 演算法3-1 | 輸入:...表示<font color="#f00">。<font> | 輸入:...表示<font color="#08f">,大小為 m*p;入口在 (1, 1)、出口在 (m, p)</font> |
| 3-30 | 演算法3-1 | 輸出:...的<font color="#f00">路徑。<font> | 輸出:...的<font color="#08f">路徑</font> (省略"。")|
| 3-32 | 程式3-15 | 2 $\quad$ struct position <font color="#f00">Stack[m*p]<font>; | 2 $\quad$ struct position <font color="#08f">* Stack</font>; |
| 3-32 | 程式3-15 | 12$\quad${$\quad$ struct position step; | 12$\quad${$\quad$ struct position step; <font color="#08f"><br>13$\quad \quad$ Stack = new struct position [m*p]; </font> <br> (註:12行s~ 與 13行S~ 請對齊) |
| 3-32 | 程式3-15 | 行號 <font color="#f00">13-29</font> | 行號 <font color="#08f">14-30</font> |
| 3-32 | 程式3-15 | <font color="#f00">30</font>$\quad\quad$return; | <font color="#08f">31$\quad\quad$delete [] Stack; <br> 32</font>$\quad\quad$return; |
| 3-32 | 程式3-15 | 行號 <font color="#f00">31-37</font> | 行號 <font color="#08f">33-39</font> |
| 3-32 | 程式3-15 | <font color="#f00">37$\quad\quad$//</font>輸出:”此迷宮無出路”<br> <font color="#f00">38$\;\;$} | <font color="#08f">39</font>$\quad\quad$輸出:”此迷宮無出路”<font color="#08f">;<br> 40 $\ \ \quad$ delete [] Stack;<br> 41 $\;\;$}</font> |
| 3-51 | 演算法3-5 |22 $\quad$while (x=pop() != “#”) <font color="#f00">output(x);</font> | 22 $\quad$while (x=pop() != “#”) <font color="#08f"> push_opn(get_prefix(x)); |
| 4-12 | -4~-2 |  | ...包括 3 個鏈結的異動。事實上 (2) 和 (3) 可同時完成(如程式 4-3 所示)。我們還得考慮 p 為 NULL 的情形,<font color="#08f">亦即整個串列是空的(程式中 p->next 在 p 是 NULL 時會中斷執行)!</font> 此時 ... <br>(註:此兩段請合併,加入"<font color="#08f">亦即整個串列是空的(程式中 p->next 在 p 是 NULL 時會中斷執行)!</font>"程式碼字體是 courier new。)|
| 4-14 | 程式4-4前一行 | 下面的程序可完成這個需求。 | <font color="#08f">請留意 p 甚至於 p->next 有可能是 NULL 的情形!</font> 下面的程序... <br>(註:程式碼字體是 courier new。)|
| 4-19 | 行-7 | s->link 應為 <font color="#f00">NULL</font>(它本是第一節點,反向後則成最後節點),此時 <font color="#f00">r</font> 應為 | s->link 應為 <font color="#08f">NULL</font>(它本是第一節點,反向後則成最後節點),此時 <font color="#08f">t</font> 應為 <br>(註:<font color="#08f">NULL/t</font> 字體皆是 courier new。)|
| 4-19 | 行-4 | 由圖 <font color="#f00">14</font> \(c)-(e) 可知 ... 順勢平移(見圖 <font color="#f00">14</font> (f)) | 由圖 <font color="#08f">14-11</font> \(c)-(e) 可知 ... 順勢平移(見圖 <font color="#08f">14-11</font> (f))|
| 4-19 | 行-3 | s-link,各節點... | s-link<font color="#08f"> (設之為t)</font>,各節點... <br>(註:<font color="#08f">(、)</font> 是全形括號、 <font color="#08f">t</font> 字體是 courier new。)|
| 4-21 | 行1 | t、s、r 的處理<font color="#f00">,</font> | t、s、r 的處理<font color="#08f">(見圖4-11 (f)),</font><br>(註:外層括號<font color="#08f">(、)</font> 是全形、"(f)" 則是半形。)|
| 4-21 | 行2 | (s->link = t;)<font color="#f00">;</font> | (s->link = t;)<font color="#08f">(見圖 \(c));</font><br>(註:外層括號<font color="#08f">(、)</font> 是全形、"\(c)" 則是半形。)|
| 4-21 | 行3 | 屆時 r 必為 NULL<font color="#f00">!</font> | 屆時 r 必為 NULL<font color="#08f">(見圖 (e));</font><br>(註:外層括號<font color="#08f">(、)</font> 是全形、"(e)" 則是半形。)|
| 4-21 | 行3 | 初始化指標 r、s <font color="#f00">(見圖11 (f))</font> | 初始化指標 r、s <br>(註:刪除之)|
| 4-21 | 行4 | ... 態(比較圖 <font color="#f00">11</font> (d)、(f)) | ... 態(比較圖 (d)、(f)) <br>(註:刪除之)|
| 4-23 | 程式 4-10,行號17 | 17$\qquad$if (top ++ NULL) top = x; | 17$\qquad$if (top ++ NULL) top = x;$\qquad$<font color="#08f">// 17、18行非必要,可省略;解釋於後</font><br>(註:加在行末)|
| 4-40 | 程式4-18 | 37$\quad$while (p!=head_a &&<font color="#f00"> p</font>!=head_b)| 37$\quad$while (p!=head_a &&<font color="#08f"> q</font>!=head_b)|
| 4-41 | 註腳19,行2-3 | $\quad$<br><font color="#f00">$\quad$x</font> = NewTerm(coef, expo); <br>InsertLast(x, last_a);| <br><font color="#08f">x</font> = NewTerm(coef, expo); <br>InsertLast(x, last_a); <br>(註:此兩行左緣對齊)|
| 4-44 | 7-8 | A(x) = <font color="#f00">-4</font>x²+1<br>B(x) = <font color="#f00">4</font>x³<font color="#f00">-9</font>x²+2x-3 | A(x) = <font color="#08f">3</font>x²+1<br>B(x) = <font color="#08f">6</font>x³<font color="#08f">+9</font>x²+2x-3 |
| 4-44 | 圖4-30 |  | |
|4-48 | 1-2 | 並不完全相同<font color="#f00">(如此繪製僅為方便後續畫出稀疏矩陣 如圖4-32),但各指標欄位實體空間的大小是相同的!</font> | 並不完全相同<font color="#08f">(例如:row和col是整數、value可能是整數或其它、down和right則是節點指標),如此繪製僅為方便後續畫出稀疏矩陣如圖4-32。</font> [註:上列 row, col, value, down 和 right 的字型請用 courier new] |
|4-66 | 第5題,行-1 | $x_n, y_n, y_{n+1},$ <font color="#f00">$x$</font>$_{n+2}, ... ,y_m$ | $x_n, y_n, y_{n+1},$ <font color="#08f">$y$</font>$_{n+2}, ... ,y_m$ |
|5-88 | 程式5-2,行8 | AVLRoot | AVLRoot<font color="#08f">;</font> |
| 6-11 | 行6 | 除了起點和終點可能相同外,其它的頂點皆不同的路徑。 | 除了起點和終點可能相同<font color="#08f">(該點走訪恰兩次)</font>外,其它的頂點皆不同<font color="#08f">(走訪僅一次)</font>的路徑。 |
| 6-52 | 行-1 | ...即可得解。 | ...即可得解。<font color="#08f">為求出最短路徑,可加入「頂點連接陣列」*C*,容後解釋。</font> |
| 6-53 | 演算法 6-8,輸出 | 輸出:*G* 中 *u* 到 *v* 的最短距離,*v*∈*V*,*v*≠*u* | 輸出:*G* 中 *u* 到 *v* 的最短距離<font color="#08f">*D*[*v*]</font>,*v*∈*V*,*v*≠*u*<font color="#08f">;頂點連接陣列*C*</font> |
| 6-53 | 演算法 6-8,輸出、行1-5 | | |
| 6-57 | 行8 | <font color="#f00">倘若</font>用空間 *O*(*n*+*e*) 的相鄰串列 | <font color="#08f">亦可</font>用空間 *O*(*n*+*e*) 的相鄰串列 |
| 6-57 | 演算法 6-9,輸入 | 輸入:...,相鄰<font color="#f00">串列</font>*E*,... | 輸入:...,相鄰<font color="#08f">串列或矩陣</font>*E*, |
| 6-57 | 演算法 6-9,輸出 | 輸出:*u* 到 *v* 的最短距離,*v*∈*V*,*v*≠*u* | 輸出:<font color="#08f">*G* 中 </font> *u* 到 *v* 的最短距離<font color="#08f">*D*[*v*]</font>,*v*∈*V*,*v*≠*u*<font color="#08f">;頂點連接陣列*C*</font> |
| 6-59 | 演算法 6-10,輸入第2行 | 輸入:... 演算法6-8所得出的頂點連接<font color="#f00">矩陣</font> *C* | 輸入:... 演算法6-8<font color="#08f">或6-9 </font>所得出的頂點連接<font color="#08f">陣列</font> *C* |
| 6-59 | 演算法 6-10,行號2 | // *toString*(*v*) 將 *v* 轉成字元資料型態 | // *toString*(*v*) 將<font color="#08f">整數</font> *v* 轉成字元資料型態 |
|6-67 | 圖 6-41 |  |  <br>註:去除分隔垂直線 |
|6-83 | 程式6-5 行號65、66 |  |  註:65行 "p->"之前加一空格 |
| 7-52 | 第7題 | (b) 用<font color="#f00">鍵</font>結串列實作最小(大)堆積 | 用<font color="#08f">鏈</font>結串列實作最小(大)堆積 |
#### [以下僅供參考,毋庸修改]
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
| 4-23 | 程式4-10 | 16$\quad\quad$x = NewNode(element); <br><font color="#f00">17$\quad\quad$if (top == NULL) top = x; <br> 18$\quad\quad$else <br>19$\quad\quad${$\quad$ x->link = top; <br>20$\quad$ $\quad\quad$ top = x; <br>21$\quad\quad$}| 16$\quad\quad$x = NewNode(element); <br><font color="#08f">17$\quad\quad$x->link = top; <br>18$\quad$$\quad$top = x; </font> |
| 4-24 | 程式4-10 | 行號 <font color="#f00">22-35</font> | 行號 <font color="#08f">19-32</font> |
## 修訂第三版 (2023/2/14 ~ 2023/9)
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
|1-3| 第3段第2行 | 與演算法之間確實有緊密結合的關係 | 與演算法之間確實有緊密結合的關係$^\color{green}1$ (插入註脚1如下) <font color="#08f">1 瑞士計算機學家 Niklaus Emil Wirth 寫過名為Algorithms + Data Structures = Programs 的鉅著,顯見資料結構與演算法唇齒相依、相輔相成的關係。Wirth 教授因在程式語言設計上的貢獻,於1984年獲頒圖靈獎 (Turing Award)。</font> (其它註脚編號依序遞增)|
|1-4 | 註脚3第3行 | 作者認為 C++<font color="#f00">或Java (C++ Builder 或J Builder) </font>也是 | 作者認為C++<font color="#08f">、Java(視窗化的C++ Builder、J Builder)或Python </font>也是) |
|1-4 | 註脚3第4-5行 | 放在<font color="#f00">資料結構</font>本身上,降低因物件導向設計<font color="#f00">或視窗程式設計</font>的引入 | 放在<font color="#08f">深耕資料結構</font>本身上,降低因物件導向設計<font color="#08f">、視窗程式設計或各類函式庫</font>的引入 |
|1-6 | -1 | 演算法<font color="#f00">的明確</font>定義 | 演算法<font color="#08f">明確的</font>定義 |
|1-8 | 5 | 以<font color="#f00">程序</font> (procedure) 或<font color="#f00">函數</font> (function) | 以<font color="#08f">「程序」</font> (procedure) 或<font color="#08f">「函數」</font> (function) |
|1-11 | 1 | 程式1-1第1行定義了一個<font color="#f00">巨集</font> (macro) | 程式1-1第1行定義了一個<font color="#08f">「巨集」</font> (macro) |
|1-11 |7-8 | 第2行<font color="#f00">參數中的data</font>為欲排序元素所在的整數陣列 | 第2行<font color="#08f">程序selectionSort的參數data[]</font>為欲排序元素所在的整數陣列 |
|1-11 |10 | 並<font color="#f00">記得</font>測試足量的資料。 | 並<font color="#08f">務必</font>測試足量的資料。<font color="#08f">程式1-2 是個實作的結果—仍有修繕優化的空間,但已可提供驗証和測試的需求。</font> |
|1-11 |10行之後 | <font color="#f00">目前無程式1-2</font> | $\color{green}{(加入程式1-2)}$ |
|1-11 |註脚4 | <font color="#f00">4</font> $\quad$ 請留意<font color="#f00">其定義方式可能因編譯器不同而有所不同</font> | <font color="#08f">5</font> $\quad$ 請留意<font color="#08f">:定義方式可能因編譯器不同而有所不同</font>|
|1-11~13 |程式1-2之後 | <font color="#f00">程式1-2之後</font> | <font color="#08f">程式1-2第2行引用了 time.h,它包含計時型態clock_t(長整數)、計時函數clock()與時間常數CLOCK_PER_SEC,可用來取得處理器執行程式的時間(請見第9、14、16、18行;其中第18行以double型態執行(tx-t0)求算執行selectionSort程序前後的clock間隔數目,將之除以CLOCK_PER_SEC即可取得以秒為單位的執行時間),方便做演算法的效能評估 (performance evaluation)。第5~7行對副程式(程序、函數)genRndData、selectionSort、printData做預先宣告 (prototype declaration),其正式宣告即可在主程式main()之後詳述,目的是讓檢視程式者可及早讀到主程式,瞭解程式的概觀;此三個副程式也讓整個流程因不同目的而歸納命名,使主程式釋義清晰條理,便於閱讀,提高了可讀性$^6$ (readability) ;還可以重複使用(第17、25行皆呼叫了printData),於是整個程式更加精簡順暢。第23和24行分別有srand(time(NULL)) 和rand(),前者取得當時時間做為隨機亂數種子 (seed) ,後者取得隨機亂數(在此因 % MAX_SIZE,其範圍為0~MAX_SIZE)。請留意:在此的輸入和輸出指令用的是scanf和printf$^7$ 。</font>|
|1-1x |程式1-2之後 | <font color="#f00">上面所加內文含註脚6</font> | <font color="#08f">6 $\quad$ Donald Knuth提倡的文學程式設計 (literal programming),即强調程式碼應同時讓編譯器和人看懂!Knuth教授因其在演算法分析、程式語言設計和系列著作The Art of Computer Programming的貢獻,於1974年獲得圖靈獎。</font>|
|1-1x |程式1-2之後 | <font color="#f00">上面所加內文含註脚7</font> | <font color="#08f">7$\quad$ 習慣用cin和cout指令的讀者,請於程式適當處加入:</font> $\text{# include <iostream>}$ $\\ \mbox{using namespace std;}$ |
|1-10 |14 | 對程式碼 <font color="#f00">再利用</font> (reuse) 和<font color="#f00">除錯</font> (debug) | 對程式碼 <font color="#08f">「再利用」</font> (reuse) 和<font color="#08f">「除錯」</font> (debug) |
|1-12 |12~13 | 程式的流程將在 <font color="#f00">呼叫程序</font> (procedure call) | 程式的流程將在 <font color="#08f">「呼叫程序」</font> (procedure call) |
|1-12 |14 | 的正確性由<font color="#f00">系統堆疊</font> (system stack) | 的正確性由<font color="#08f">「系統堆疊」</font> (system stack) |
|1-13 |-3 | 傳回 n\*X(n-1)<font color="#f00">。</font> 請看程式1-<font color="#f00">2</font>。| 傳回 n\*X(n-1)<font color="#08f">;</font> 請看程式1-<font color="#08f">3</font>。 |
|1-13 |-2 | 整數 n 已為 <font color="#f00">1</font> 時| 整數 n 已為 <font color="#08f">0</font> 時 (<font color="#08f">0 字體為Courier New)</font>|
|1-13 |-1 | 回<font color="#f00"> 1 </font>繼續呼叫X(<font color="#f00">0</font>)是沒有意義 | 回<font color="#08f">1(亦可定n==1為終結條件;</font>繼續呼叫X(<font color="#08f">-1</font>)是沒有意義|
|1-13 |程式1-2標題 | 程式1-<font color="#f00">2</font> | 程式1-<font color="#08f">3</font>|
|1-13 |程式1-2 (行2) | 2$\qquad$ {$\quad$if (n == <font color="#f00">1</font>) return 1; | 2$\qquad$ {$\quad$if (n == <font color="#08f">0</font>) return 1;|
| 2-14 | 演算法2-3 | 4$\qquad$B[j][i]<font color="#f00">=</font>A[i][j]; | 4$\qquad$B[j][i]<font color="#08f"> = </font>A[i][j]; (<font color="#08f">等號前後加一空格</font>) |
| 2-15 | 演算法2-4 | 輸出:矩陣C ... | 輸出:<font color="#08f">mxn</font>矩陣C ... |
|4-23| 程式4-10 | 9 if (p == <font color="#f00">null</font>) { ... } | 9 if (p == <font color="#08f">NULL</font>) { ... } |
|4-24| 程式4-10 | 25 if (top == NULL)<font color="#f00">;</font> | 25 if (top == NULL) |
|4-35| 程式4-16 | 3 for (p=<font color="#f00">header</font>->next; (p->data!=target && p!=header); p=p->next) ; | 3 for (p=<font color="#08f">head</font>->next; (p->data!=target && p!=header); p=p->next) ; |
|4-35| 程式4-16 | 3 for (p=header->next; (p->data!=target && p!=<font color="#f00">header</font>); p=p->next) ; | 3 for (p=header->next; (p->data!=target && p!=<font color="#08f">head</font>); p=p->next) ; |
|4-35| 程式4-16 | 3 for (p=header->next; (p->data!=target && p!=header); p=p->next)<font color="#f00"> ;</font> | 3 for (p=header->next; (p->data!=target && p!=header); p=p->next)<font color="#08f">;</font> (去除空格) |
|4-35| 1 | ... p 的初始值是 <font color="#f00">header</font>->next,... | ... p 的初始值是 <font color="#08f">head</font>-->next,...|
|4-35| 3 | ... (p->data!=target && p!=<font color="#f00">header</font>)... | ... (p->data!=target && p!=<font color="#08f">head</font>)... |
|4-35| 4 | ...由 p!=<font color="#f00">header</font> 來確認... | ...由 p!=<font color="#08f">head</font> 來確認... |
|4-35| 5 | ...,至 p==<font color="#f00">header</font> 則遍訪所有節點);... | ...,至 p==<font color="#08f">head</font> 則遍訪所有節點);... |
|4-35| 7 | ...(p->data!=target && p!=<font color="#f00">header</font>)兩條件順序可以更動,... | ...(p->data!=target && p!=<font color="#08f">head</font>)兩條件順序可以更動,... |
|4-35| 4-16-1 | 3 for (q=first, p= header->next; (p->data!=target && p!=header); q=p, p=p->next); | 3 for (q=first, p=head->next; (p->data!=target && p!=head); q=p, p=p->next); (刪除p= head->next間空格) |
|4-35| 4-16-1 | 3 for (q=<font color="#f00">first</font>, p=<font color="#f00">header</font>->next; (p->data!=target && p!=<font color="#f00">header</font>); q=p, p=p->next); | 3 for (q=<font color="#08f">head</font>, p=<font color="#08f">head</font>->next; (p->data!=target && p!=<font color="#08f">head</font>); q=p, p=p->next); |
|4-35| 4-16-1 | 4 if (p==<font color="#f00">header</font>) return -1; | 4 if (p==<font color="#08f">head</font>) return -1; |
|4-36| 1 |(p->data!=target && p!=<font color="#f00">header</font>);... | (p->data!=target && p!=<font color="#08f">head</font>);... |
|4-42| 程式4-18 |62 { struct <font color="#f00">Polynode</font> *p... | 62 { struct <font color="#08f">PolyNode</font> *p... |
|4-45| 程式4-19 | 1 struct PolyNode * ClearTerm(struct <font color="#f00">node</font> * head) | 1 struct PolyNode * ClearTerm(struct <font color="#08f">PolyNode</font> * head) |
|4-46| 程式4-19 | 14 <font color="#f00">last_s_</font> = AttachLast(z, last_s); | 14 <font color="#08f">last_s</font> = AttachLast(z, last_s); |
|4-57| 程式4-25 | 7 void DeleteHDList(<font color="#f00">truct</font> Dnode *x) | 7 void DeleteHDList(<font color="#08f">struct</font> Dnode *x) |
|5-5| 圖5-2 (c) | 嘉義、台南之間無權重(票價)値| <font color="#08f">139</font> (自强號票價139)|
|5-6| -7 | 「中間節點」(<font color="#f00">intenal</font> node)。 | 「中間節點」(<font color="#08f">internal</font> node)。 |
|5-15| -2 | 其中$v_1+v_2+...+v_m=$<font color="#f00">$K$</font> 。... | 其中$v_1+v_2+...+v_m=$<font color="#08f">$k$</font> 。... |
|5-31| 圖5-24欄3第10列 | <font color="#f00">Inorder</font>(C的左子樹指標) | <font color="#08f">inorder</font>(C的左子樹指標) |
|5-32| 圖5-24欄3第3列 | <font color="#f00">Inorder</font>(D的左子樹指標) | <font color="#08f">inorder</font>(D的左子樹指標) |
|5-32| 圖5-24欄3第6列 | <font color="#f00">Inorder</font>(E的左子樹指標) | <font color="#08f">inorder</font>(E的左子樹指標) |
|5-32| 圖5-24欄3第7列 | <font color="#f00">Inorder</font>(-的左子樹指標) | <font color="#08f">inorder</font>(-的左子樹指標) |
|5-33| 6 | <font color="#f00">Node</font>->data | <font color="#08f">node</font>->data |
|5-35| 程式5-6 | 13 { struct <font color="#f00">stackNode</font> old_top; | 13 { struct <font color="#08f">StackNode</font> old_top; |
|5-35| 程式5-6 | 23$\quad\quad$<font color="#f00">StackEmpty(); | 23 $\quad\quad$<font color="#08f">return NULL;</font> |
|5-39| 程式5-6-1 | 51 } // 印<font color="#f00">入</font>node->data、... | 51 } // 印<font color="#08f">出</font>node->data、... |
|5-39| -4 | (恰為 $LRV$ <font color="#f00">的</font>反轉) | (恰為 $LRV$ <font color="#08f">的</font>反轉) (字體請與內文同) |
|5-40| 程式5-6-2 | 12 void <font color="#f00">push_data</font> (... | 12 void <font color="#08f">push_node</font> (... |
|5-40| 程式5-6-2 | 13 { struct <font color="#f00">stackNode</font> *old_top; | 13 { struct <font color="#08f">StackNode</font> *old_top; |
|5-47| -3 | 呼叫<font color="#f00">copy</font>程序,... | 呼叫<font color="#08f">Copy</font>程序,... |
|5-49| 程式5-10 | 1 ...(struct <font color="#f00">BTreeNodes</font> * node) | 1 ...(struct <font color="#08f">BTreeNode</font> * node) |
|5-49| 程式5-12 | 5 new-><font color="#f00">rightthead</font> = p->rightthread; | 5 new-><font color="#08f">rightthread</font> = p->rightthread; |
|5-49| 程式5-12 | 9 p-><font color="#f00">rightthead</font> = 0; | 9 p-><font color="#08f">rightthread</font> = 0; |
|5-57| -4 | 著名的堆<font color="#f00">疊</font>排序 | 著名的堆<font color="#08f">積</font>排序 |
|5-59| 程式5-13 | 5 { if (n == maxsize) HeapFull(); | 5 { if (n == maxsize <font color="#08f">- 1</font>) HeapFull(); |
|5-59| -5 | 為x在堆<font color="#f00">疊</font>中的適當存放位置 | 為x在堆<font color="#08f">積</font>中的適當存放位置 |
|5-60| 圖 5-37 名 | 圖 5-37 最大堆<font color="#f00">疊</font>的刪除 | 圖 5-37 最大堆<font color="#08f">積</font>的刪除 |
|5-69| 程式5-17-1 | 25 { struct BSTreeNode *p<font color="#f00">(空格)</font>*q; | 25 { struct BSTreeNode *p<font color="#08f">, </font>*q; |
|5-89| 表5-5第4列 | *w* 在 *p* <font color="#f00">左</font>子樹的右子樹內(空格) | *w* 在 *p* <font color="#08f">右</font>子樹的右子樹內(空格) |
|5-95| 表5-7欄4第4列 | ...右子樹 *T*~2~ 不低於<font color="#f00">右</font>子樹 *T*~1~... | ...右子樹 *T*~2~ 不低於<font color="#08f">左</font>子樹 *T*~1~... |
| 6-2 | -5 | 早在 <font color="#f00">1763</font> 年 | 早在 <font color="#08f">1736</font> 年 |
|6-3| 8 | 若且唯若恰有兩個(或沒有)<font color="#f00">項</font>點 | 若且唯若恰有兩個(或沒有)<font color="#08f">頂</font>點
|6-5| 圖6-5(c)| (<font color="#f00">a</font>) | (<font color="#08f">c</font>)
|6-10| 3 | 而 B 相鄰<font color="#f00">到</font> A(或從 A 相鄰) | 而 B 相鄰<font color="#08f">自</font> A(或從 A 相鄰) |
|6-10| 子圖 | 必須滿足 *V'*<font color="#f00">∈</font>*V* 且 *E'*<font color="#f00">∈</font>*E*。 | 必須滿足 *V'*<font color="#08f">⊆</font>*V* 且 *E'*<font color="#08f">⊆</font>*E*。 |
|6-19| 演算法6-1 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1} | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font> |
|6-20| 演算法6-2 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1} | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font> |
|6-20| 演算法6-2 | 8 for (...即 <font color="#f00">visted[w]</font> ≠ 1) | 8 for (...即 <font color="#08f">visited[w]</font> ≠ 1) |
|6-21| 演算法6-3 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1} | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font> |
|6-22| 演算法6-3 | 13 Add_Queue<font color="#f00">[w]</font>; | 13 Add_Queue<font color="#08f">(w)</font>; |
|6-23| 演算法6-4 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1} | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font> |
|6-26| 演算法6-5 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1},\| *V* \|=n,\| *E* \|=e | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font>,\| *V* \|=n,\| *E* \|=e |
|6-36| 演算法6-6 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1},\| *E* \|=e,... | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font>,\| *E* \|=e,... |
|6-41| 演算法6-6-1 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1},\| *E* \|=e,... | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font>,\| *E* \|=e,... |
|6-53| 演算法6-7 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1},... | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font>,... |
|6-57| 演算法6-7-1 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1},... | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font>,... |
|6-57| -2 | ...建立最小堆<font color="#f00">疊</font>-以距離短者為優先。... | ...建立最小堆<font color="#08f">積</font>-以距離短者為優先。... |
|6-58| 演算法6-8 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1},... | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font>,... |
|6-59| 演算法6-8 | 4 ..."]==>"<font color="#f00">\|\|</font>r; | 4 ..."]==>"<font color="#08f">+</font>r; |
|6-59| 演算法6-8 | 5 ..."]==>"<font color="#f00">\|\|</font>r; | 5 ..."]==>"<font color="#08f">+</font>r; |
|6-64| 演算法6-9 | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1},... | 輸入:圖形 *G*=(*V*,*E*),*V*={0,1,2,...,*n*-1}<font color="#08f">,E(相鄰矩陣 or 相鄰串列)</font>,... |
|6-78| -1 | ... <font color="#f00">AOV[i] = NULL</font> | ... <font color="#08f"> (換行) { AOV[i].arc = NULL; AOV[i].count = 0; (換行) }</font> |
|6-79| 程式6-4| <font color="#f00">23 if (head == last) head->next = q;</font> | <font color="#08f">(直接刪除)</font> |
|6-80| 程式6-4| 46 preparePrint(id) ... | 46 preparePrint(id)<font color="#08f">;</font> ... |
|6-82| 程式6-5| 53 <font color="#f00">for (j=0; j<n ;j++)</font> | 53 <font color="#08f">for (j=n-1; j>=0 ;j--)</font> |
|6-82| 程式6-5 | 行號<font color="#f00">47下一行(目前無行號)</font>| 加入行號<font color="#08f">48 |
|6-82| 程式6-5 | 行號<font color="#f00">48~58</font>| 行號<font color="#08f">49~59 </font> |
|6-82| 1 | 程式6-5第47~<font color="#f00">49</font>行 | 程式6-5第47~<font color="#08f">50</font>行 |
|6-82| 5 | 相鄰陣列<font color="#f00">*W* (52~57 </font>行... | 相鄰陣列<font color="#08f">W (53~58</font>行...(W字體為Courier New、無斜體) |
|6-82| 7 | (<font color="#f00">55</font>行... | (<font color="#08f">56</font>行... |
|6-82| -4 | (<font color="#f00">56</font>行)...當<font color="#f00">52~57</font> | (<font color="#08f">57</font>行)...當<font color="#08f">53~58</font> |
|6-82| -2 | ... AOV[i].<font color="#f00">arc</font>則記錄了i 直接前接點的個數<font color="#f00">,</font>| ... AOV[i].<font color="#08f">count</font>則記錄了 i 直接前接點的個數<font color="#08f">(56行),</font> |
|7-12| 演算法7-3 | 6$\quad$... (j-h)<font color="#f00">></font>0 | 6$\quad$... (j-h)<font color="#08f">>=</font>0 |
|7-24| 演算法7-7 | 2 { int i, j; | 2 { int i, j, <font color="#08f">target</font>; |
|7-27| 演算法7-8 | 14 if (left<j) swap(&data[i], &data[j]) | 14 if (left<j) swap(&data[i], &data[j])<font color="#08f">;</font> (新增 ; ) |
|7-31| 演算法7-9 | 1 for (q=<font color="#f00">0</font>, i=1; i<n; i++) | 1 for (q=<font color="#08f">A[0]</font>, i=1; i<n; i++) |
|7-31| 演算法7-9 | 2 if (<font color="#f00">data[i]</font>>q) q = <font color="#f00">data[i]</font>; | 2 if (<font color="#08f">A[i]</font>>q) q = <font color="#08f">A[i]</font>; |
|7-31| 演算法7-9 | 4 int * C = int new [m] |4 int * C = int new [m<font color="#08f">+1</font>] |
|7-31| 演算法7-9 | 5 for (i=0; i<m; i++)... |5 for (i=0; i<<font color="#08f">=</font>m; i++)... |
|7-31| 演算法7-9 | 7 for (i=0; i<m; i++)... |7 for (i=0; i<<font color="#08f">=</font>m; i++)... |
|7-31| 演算法7-9 | 8 for (j=<font color="#f00">1</font>; j<n; j++) | 8 for (j=<font color="#08f">0</font>; j<n; j++) |
|7-34| 6 | 它<font color="#f00">的大小比較是</font>與 ... 位數有關。 | 它<font color="#08f">排序的方式</font>與 ... 位數有關。 |
|7-34| 12 | ...<font color="#f00">。</font>我們先看... | ...<font color="#08f">;各位數的排序並不使用比較大小的運算,而是用資料搬移 (data movement) 和佇列的結構來完成;</font>我們先看... |
|7-38| 演算法7-10 | 7$\quad$for (j=0; j<<font color="#f00">10</font>; j++) | 7$\quad$for (j=0; j<<font color="#08f">n</font>; j++) |
|7-52| 頁碼 | <font color="#f00">1-52</font> | <font color="#08f">7-52</font> |
|7-52| 1 | 直接用挑選<font color="#f00">或</font>排序 | 直接用挑選排序(刪去"或") |
## 第三版 (2023/2/9 前)

### 第一章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
| 1-2 | -3 | 「資料結構」(data <font color="#f00">structurs</font>) | 「資料結構」(data <font color="#08f">structures</font>)|
| 1-10 | 程式1-1行號2 | <font color="#f00">S</font>electionSort | <font color="#08f">s</font>electionSort |
| 1-13 | 圖1-2兩處 | <font color="#f00">S</font>electionSort | <font color="#08f">s</font>electionSort |
| 1-14 | 註釋8行1~3 | 費氏數列出現於1202年 Leonardo Fibonacci的著作*Liber Abaci* ;其中<font color="#f00">有個假設</font>介紹的費氏兔子問題 ... 可長為成兔,<font color="#f00">並生出一對費氏小兔</font>,且費氏兔子不會死去 ... 此即為第$n$項費氏數列<font color="#f00">!</font> | 費氏數列出現於1202年<font color="#08f">Leonardo Fibonacci</font>的著作*Liber Abaci*;其中介紹的費氏兔子問題 ... 可長為成兔,<font color="#08f">再一個月即可生育 出一對小兔,之後每月皆然</font>,且費氏兔子不會死去 ... 此即為第$n$項費氏數列<font color="#08f">:$F_n = F_{n-1}$ (上個月的兔子對數)$+F_{n-1}$ (上上個月的兔子會 生出小兔的對數);$F_0 = 0,F_1 = 1$。</font> |
| 1-16 | 演算法1-2 | 行號 <font color="#f00">2, 3, 4, 5</font> | <font color="#08f">3, 4, 5, 6</font> || 1-16 | 演算法1-2 | 行號 <font color="#f00">2, 3, 4, 5</font> | <font color="#08f">3, 4, 5, 6</font> |
| 1-16 | 演算法1-2 | 5$\quad\quad$towerHanoi(n-1, B, <font color="#f00">C</font>, <font color="#f00">A</font>) | 5$\quad\quad$towerHanoi(n-1, B, <font color="#08f">A</font>, <font color="#08f">C</font>) |
| 1-16 | 程式1-4 | 行號 <font color="#f00">4</font>(兩個中的第二個) | <font color="#08f">6</font> |
| 1-18 | -8 | $n$個<font color="#f00">元素</font>的排列共有$n!$種。 | <font color="#08f">一般而言,</font>$n$個<font color="#08f">相異元素</font>的排列共有$n!$種。 |
| 1-20 | 4 | 假設<font color="#f00">c[0~3]</font>={‘A’, ‘B’, ‘C’, ‘D’}; | 假設<font color="#08f">char c[4]</font>={‘A’, ‘B’, ‘C’, ‘D’}; |
|1-27 | 5 | $9n^2+11\le cn$ | $9n^2\color{cyan}{+n}+11\le cn$ |
|1-31 | -9 |程式1-<font color="#f00">4</font>提供了 $n$ 個陣列元素 ... | 程式1-<font color="#08f">6</font>提供了 $n$ 個陣列元素 ... |
|1-32 | 1 | 根據定義可知:程式1-<font color="#f00">7</font> ... | 根據定義可知:程式1-<font color="#08f">9</font> ... |
|1-33 | 1 | ... 的代價),根據定義可知:程式1-<font color="#f00">7</font> ... | ... 的代價),根據定義可知:程式1-<font color="#08f">9</font> ... |
| 1-37 | 9 | (j) $n^k\color{red}{+ \varepsilon}+n^klogn=\Theta(n^k\color{red}{+ \varepsilon})$ | (j) $n^{k\color{cyan}{+ \varepsilon}}+n^klogn=\Theta(n^{k\color{cyan}{+ \varepsilon}})$ |
| 1-37 | 10 | (k) ... = *O*($\color{red}{100}n^22^n$) | (k) ... = *O*($n^22^n$) |
### 第二章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
| 2-7 | 圖2-4三處 | <font color="#f00">S</font>electionSort | <font color="#08f">s</font>electionSort |
| 2-8 | 註釋5 | n 用傳<font color="#f00">位</font>法傳遞 | n 用傳<font color="#08f">值</font>法傳遞 |
| 2-14 | 演算法2-3 | 輸出:矩陣B ... | 輸出:<font color="#08f">nxm</font>矩陣B ... || 2-15 | 演算法2-4 | 輸出:矩陣C ... | 輸出:<font color="#08f">mxn</font>矩陣C ... |
| 2-17 | 演算法2-5 | 輸出:矩陣C ... | 輸出:<font color="#08f">mxp</font>矩陣C ... |
| 2-18 | 演算法2-6 | 7 $\qquad$M[i][<font color="#f00">i</font>] | 7 $\qquad$M[i][<font color="#08f">j</font>] |
| 2-25 | 7 | 皆為一樣<font color="#f00">。</font> | 皆為一樣<font color="#08f">。此現象稱為「隨機存取」(random access);陣列即為隨機存取結構。</font> || 2-31 | -2 | 求得其位址值<font color="#f00">。</font>圖2-18演算法 ... | 求得其位址值<font color="#08f">—隨機存取的性質展露無遺。</font>圖2-18演算法 ... |
| 2-34 | 11題末句 | 設計一個<font color="#f00">演算法</font> | 設計一個<font color="#08f">計算式</font> |
### 第三章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
|3-11|-6|定義Stack為一結構物件<font color="#f00">;</font>此後... | 定義Stack為一結構物件<font color="#08f">(第6行為靜態宣告;亦可在程式中以 StackType * x; 動態宣告結構物件x);</font>此後...|
| 3-25 | 圖3-14 第1列第1欄 | <font color="#f00">dir</font> | <font color="#08f">d</font> |
|3-25 | 圖3-14 第2列第1欄 | move[<font color="#f00">dir</font>].<font color="#f00">x</font> | move[<font color="#08f">d</font>].<font color="#08f">dx</font> |
| 3-25 | 圖3-14 第3列第1欄 | move[<font color="#f00">dir].y | move[<font color="#08f">d</font>].<font color="#08f">dy</font> |
|3-28|-10 |前一步為(7,6,<font color="#f00">E</font>) | 前一步為(7,6,<font color="#08f">SE</font>) |
|3-28|-7 |目前位置和前往方向<font color="#f00">W</font>):(7,6,<font color="#f00">W</font>) | 目前位置和前往方向<font color="#08f">的下一個可能NW</font>:(7,6,<font color="#f00">NW</font>) |
|3-29| 演算法3-1 -5行| 14 $\quad\quad$ i=u; j=v; <font color="#f00">dir</font>=N; |14 $\quad\quad$ i=u; j=v; <font color="#08f">d</font>=N;|
|3-36|-1|...請看範例3-1<font color="#f00">3</font>|...請看範例3-1<font color="#08f">5</font>|
### 第四章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
|4-3|7|(<font color="#f00">a</font>)$\quad$apple、peach、strawberry ... |(<font color="#08f">c</font>)$\quad$apple、peach、strawberry ... |
|4-15|程式4-5|5$\quad$... (<font color="#f00">!p</font> && p->data ... |5$\quad$... (<font color="#08f">p</font> && p->data ... |
|4-16|6|其中 <font color="#f00">!p</font> 與 p!=NULL ... |其中 <font color="#08f">p</font> 與 p!=NULL ... |
|4-17|程式4-6|3$\quad$... (<font color="#f00">!p</font> && p->data ... |3$\quad$... (<font color="#08f">p</font> && p->data ... |
|4-17|程式4-6|4$\quad$if (<font color="#f00">!p</font>) return ... |4$\quad$if (<font color="#08f">p</font>) return ... |
|4-39|程式4-17|6$\quad$struct PolyNode head_a, head_b, head_c; |6$\quad$struct PolyNode $\color{cyan}*$head_a, $\color{cyan}*$head_b, $\color{cyan}*$head_c; |
|4-39|程式4-17|7$\quad$struct PolyNode last_a, last_b, last_c; |7$\quad$struct PolyNode $\color{cyan}*$last_a, $\color{cyan}*$last_b, $\color{cyan}*$last_c; |
|4-39|程式4-17|8$\quad$struct <font color="#f00">node</font> * NewTerm |8$\quad$struct <font color="#08f">PolyNode</font> * NewTerm |
|4-39|程式4-17|32 {$\quad$struct <font color="#f00">node</font> * p |32 {$\quad$struct <font color="#08f">PolyNode</font> * NewTerm |
|4-40|程式4-17|51$\quad${$\quad$r = CopyTerm(p ); p = p->next; } |51$\quad${$\quad$r = CopyTerm(p ); <font color="#08f">InsertLast(r, last_c);</font> p = p->next; } |
|4-40|程式4-17|52$\quad$while (<font color="#f00">p</font>!=<font color="#f00">head_a</font>) |52$\quad$while (<font color="#08f">q</font>!=<font color="#08f">head_b</font>) |
|4-40|程式4-17|53$\quad${$\quad$r = CopyTerm(<font color="#f00">p</font>); <font color="#f00">p</font> = <font color="#f00">p</font>->next; } |53$\quad${$\quad$r = CopyTerm(<font color="#08f">q</font>); <font color="#08f">InsertLast(r, last_c);</font> <font color="#08f">q</font> = <font color="#08f">q</font>->next; } |
|4-40|程式4-17第2個行號54|<font color="#f00">54</font>$\quad$} |<font color="#08f">55</font>$\quad$}|
|4-41|-7程式區行號20|20 struct PolyNode AttachLast(... |20 struct PolyNode <font color="#08f">*</font> AttachLast(...|
|4-42|程式4-18|62$\quad$struct <font color="#f00">node</font> * p |62$\quad$struct <font color="#08f">Polynode</font> * p |
|4-42|-3|51$\quad${$\quad$r = CopyTerm(p ); p = p->next; } |51$\quad${$\quad$r = CopyTerm(p ); <font color="#08f">InsertLast(r, last_c);</font> p = p->next; } |
|4-42|-2|52$\quad$while (<font color="#f00">p</font>!=<font color="#f00">head_a</font>) |52$\quad$while (<font color="#08f">q</font>!=<font color="#08f">head_b</font>) |
|4-42|-1|53$\quad${$\quad$r = CopyTerm(<font color="#f00">p</font>); <font color="#f00">p</font> = <font color="#f00">p</font>->next; } |53$\quad${$\quad$r = CopyTerm(<font color="#08f">q</font>); <font color="#08f">InsertLast(r, last_c);</font> <font color="#08f">q</font> = <font color="#08f">q</font>->next; } |
|4-44|圖4-30| <font color="#f00">D</font> $\quad$ 18 $\quad$ 27 ... |$\color{cyan}{D(x)}\quad$ 18 $\quad$ 27 ...|
|4-45|3| ...旨在<font color="#f00">除</font>本回合 |...旨在<font color="#08f">清除</font>本回合|
|4-45|程式4-19| 4$\quad$// 環狀串列只 <font color="#f00">利</font>開頭空白節點 |4$\quad$//<font color="#08f">清空</font>環狀串列只<font color="#08f">留</font>開頭空白節點</font>|
|4-46|2|「稀疏矩陣」|「稀疏矩陣」 <font color="#08f">(sparse matrix)</font>|
|4-46|-9|... head_a 和 <font color="#f00">_head_b</font>|... head_a 和 <font color="#08f">head_b</font>|
|4-47|10|...五個欄位並不|... 五個欄位<font color="#08f">大小</font>並不|
|4-47|11~12|...各<font color="#f00">欄位皆為指標-</font>實體空間的大小|各<font color="#08f">指標欄位</font>實體空間的大小|
|4-52|程式4-22| 6 $\quad \quad${ $\quad$p = <font color="#f00">head</font>;|6 $\quad \quad${ $\quad$p = <font color="#08f">first</font>;|
|4-52|2| 自<font color="#f00">head</font>起逐一|自<font color="#08f">first</font>起逐一|
|4-52|-5| $\quad$for (p=<font color="#f00">head</font>; |$\quad$for (p=<font color="#08f">first</font>;|
|4-55|程式4-24| 行號<font color="#f00">7~13</font> |行號<font color="#08f">6~12</font>|
|4-57|程式4-25| 8$\quad${$\quad$if (x == <font color="#f00">first</font>) |8$\quad${$\quad$if (x == <font color="#08f">head</font>)|
### 第五章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
|5-6|註釋3|無根樹較為$\quad$調點之間|無根樹較為<font color="#08f">強</font>調點之間 |
|5-13|-2|我們在<font color="#f00">一下</font>節|我們在<font color="#08f">下一</font>節 |
|5-22|-3|會十分浪費<font color="#f00">時</font>間|會十分浪費<font color="#08f">空</font>間 |
|5-36|程式5-6行43|while ((top != NULL) ... (node !=NULL<font color="#f00">)</font>; | while ((top != NULL) ... (node !=NULL<font color="#08f">))</font>; |
|5-44|程式5-7行33、34|<font color="#f00">33</font>$\quad$<font color="#f00">return Tnode;<br><font color="#f00">34</font>$\quad$<font color="#f00">}</font>| <font color="#08f">33</font>$\quad$<font color="#08f">}<br><font color="#08f">34</font>$\quad$<font color="#08f">return Tnode;</font> |
|5-48| -5 |程式5-9第<font color="#f00">7</font>行中|程式5-9第<font color="#08f">1</font>行中|
|5-48| -3 |在第<font color="#f00">8</font>行中|在第<font color="#08f">2</font>行中 |
|5-48| -2 |當第<font color="#f00">9、10、11、12</font>行中|在第<font color="#08f">3~6</font>行中 |
|5-48| -1 |其中的第<font color="#f00">11</font>行中|其中的第<font color="#08f">5</font>行中 |
|5-49| 2 |第<font color="#f00">12</font>行亦然|第<font color="#08f">6</font>行亦然 |
|5-49| 4 |<font color="#f00">這</font>也沿用了 ... 的精神|<font color="#08f">程式5-9的設計</font>也沿用了 ... 的精神<font color="#08f">!</font> |
|5-49| -7 |... 樹的成員;第<font color="#f00">4</font>行|... 樹的成員;第<font color="#08f">5</font>行 |
|5-54| -7 | 中序後繼節*q*點<font color="#f00">。</font>此時...|中序後繼節*q*點<font color="#08f">—</font>此時... (註:破折號) |
|5-54| -6 | 指向p(<font color="#f00">q是p</font>的中序前接節點)!|指向p(<font color="#08f">p是q</font>的中序前接節點)! |
| 5-59 | 程式5-13 | 行號16 |行號15 |
|5-68| 程式5-17行8 | 8$\quad$struct BSTreeNode * <font color="#f00">InsertBST</font>|8$\quad$struct BSTreeNode * <font color="#08f">InsertBSTree</font> |
|5-68| 程式5-17行11 | 11$\quad\quad$ ... = <font color="#f00">InsertBST</font>(node->leftchild,x);|11$\quad\quad$ ... = <font color="#08f">InsertBSTree</font>(node->leftchild,x); |
|5-68| 程式5-17行13 | 13$\quad\quad$ ... = <font color="#f00">InsertBST</font>(node->rightchild,x);|11$\quad\quad$ ... = <font color="#08f">InsertBSTree</font>(node->rightchild,x); (註:可刪=前後空格使其不跳行)|
|5-77| 程式5-19行47 | 47$\quad$<font color="#f00">Struct</font> BSTreeNode|47$\quad$<font color="#08f">struct</font> BSTreeNode|
|5-77| 程式5-19行71 | 71$\quad\quad$k = <font color="#f00">k -></font>leaftchild; | 71$\quad\quad$k = <font color="#08f">k-></font>leaftchild; (刪去空k -之間空格)|
|5-82| 1~2 | 使之形成圖<font color="#f00">右</font>的二元樹 | 使之形成圖<font color="#08f">左</font>的二元樹|
|5-84| 程式5-22行22 | 22 ... <font color="#f00">* y = x->right</font>child; | 22 ... <font color="#08f">* x = y->left</font>child;|
|5-84| 程式5-22行23 | 23 ... *T2 = <font color="#f00">y->left</font>child; | 23 ... *T2 = <font color="#08f">x->right</font>child; |
|5-84| 程式5-22行24 | 24$\quad$<font color="#f00">y->left</font>child = <font color="#f00">x</font>; | 24$\quad$<font color="#08f">x->right</font>child= <font color="#08f">y</font>; |
|5-84| 程式5-22行25 | 25$\quad$<font color="#f00">x->right</font>child = T2; | 24$\quad$<font color="#08f">y->left</font>child = T2; |
|5-84| 程式5-22行26 | 26$\quad$<font color="#f00">x</font>->height = MAX(height(<font color="#f00">x</font>->leftchild), height(<font color="#f00">x</font>->rightchild)+1; | 26$\quad$<font color="#08f">y</font>->height = MAX(height(<font color="#08f">y</font>->leftchild), height(<font color="#08f">y</font>->rightchild)+1; |
|5-84| 程式5-22行27 | 27$\quad$<font color="#f00">y</font>->height = MAX(height(<font color="#f00">y</font>->leftchild), height(<font color="#f00">y</font>->rightchild)+1; | 27$\quad$<font color="#08f">x</font>->height = MAX(height(<font color="#08f">x</font>->leftchild), height(<font color="#08f">x</font>->rightchild)+1; |
|5-86|-4(第二段句尾) | <font color="#f00">。。</font> |<font color="#08f">。</font> |
|5-88|表5-4欄2標題 | 失衡節點右兒子向<font color="#f00">左</font>旋轉 |失衡節點右兒子向<font color="#08f">右</font>旋轉 |
|5-88|表5-4欄3標題 | 失衡節點向<font color="#f00">右</font>旋轉 |失衡節點向<font color="#08f">左</font>旋轉 |
|5-88|6 |「失衡節點向<font color="#f00">右</font>旋轉」。 |「失衡節點向<font color="#08f">左</font>旋轉」。|
|5-88|-4 |即可恢復平衡<font color="#f00">.</font> |即可恢復平衡<font color="#08f">。</font> (句號字型請修改) |
|5-91|程式5-23 |行號<font color="#f00">37</font> |<font color="#08f">37</font> (字型用 Courier New) |
|5-92|-5 |(node-><font color="#f00">left</font>child->data)的大小... |(node-><font color="#08f">right</font>child->data)的大小... |
|5-93| 9 |(於節 5.10.<font color="#f00">4</font> 討論),... |(於節 5.10.<font color="#08f">5</font> 討論),... |
|5-95| 程式5-22行號103~108 |行號<font color="#f00">103~108</font> |行號<font color="#08f">104~109</font> |
|5-96| 5 |(於節 5.10.<font color="#f00">4</font> 討論)! |(於節 5.10.<font color="#08f">5</font> 討論)! |
|5-96| -1 |<font color="#f00">左</font>子樹高為*h*-2 |<font color="#08f">右</font>子樹高為*h*-2 |
|5-97| 7 |<font color="#f00">首項為1</font>的費氏數列 |<font color="#08f">首、次項為1、2</font>的費氏數列 |
|5-98| 5 | $F_h=\varphi ^h/$ $\color{red}{(5)^{1/2}}$, $\varphi$ =(1+<font color="#f00">$(5)^{1/2}$</font>)/2 |$F_h=\varphi ^h/$ $\color{cyan}{\sqrt{5}}$, $\varphi$ =(1+<font color="#f00">$\color{cyan}{\sqrt{5}}$</font>)/2 |
### 第六章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
|6-4|-3| e, f <font color="#f00">五</font>條邊 | e, f <font color="#08f">六</font>條邊 |
| 6-6|-3|利用範例6-3說<font color="#f00">明</font>明此…|利用範例6-3說明此… |
| 6-13|-6|6.<font color="#f00">6</font>)和拓樸…|6.<font color="#08f">7</font>)和拓樸…|
| 6-20|演算法6-2|8$\quad$for (...<font color="#f00">visted</font>[w]|8$\quad$for (...<font color="#08f">visited</font>[w]|
| 6-20|演算法6-2|行號<font color="#f00">10~15</font> (自第二個10開始)|行號<font color="#f00">11~16</font>|
| 6-23|2|只要對G中<font color="#f00">過</font>的點u|只要對G中的點u (刪去”過”) |
| 6-27|10|可以互換的|可以互換的<font color="#08f">。</font>|
| 6-29|7|最小邊的取得|<font color="#08f">之後</font>最小邊的取得|
| 6-29|9|邊都會與第3行|邊都會<font color="#08f">參</font>與第3行|
| 6-34|程式6-2行號6|6 struct UFNode vertex [SIZE];|6 struct UFNode <font color="#08f">*</font> vertex [SIZE];|
| 6-34|9|邊都會與第3行|邊都會<font color="#08f">參</font>與第3行|
| 6-59|3~4|如圖 6-3<font color="#f00">4</font> 最右側的邊。|如圖 6-3<font color="#08f">5</font> 最右側的邊。|
| 6-59|-5|與範例6-2<font color="#f00">2</font>相似|與範例6-2<font color="#08f">3</font>相似|
| 6-59|-1|與範例6-2<font color="#f00">2</font>者幾乎一樣|與範例6-2<font color="#08f">3</font>者幾乎一樣|
| 6-71|圖6-43 |(a) … 矩陣<font color="#f00">A</font> (b) … 矩陣<font color="#f00">A+</font>|(a) … 矩陣<font color="#08f">$A\quad$</font>(b) … 矩陣<font color="#08f">$A^+$</font> (A為斜體、+為上標) |
| 6-72|圖6-45 |(a) … 矩陣<font color="#f00">A</font> (b) … 矩陣<font color="#f00">A+</font>|(a) … 矩陣<font color="#08f">$A\quad$</font>(b) … 矩陣<font color="#08f">$A^+$</font> (A為斜體、+為上標) |
### 第七章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
| 7-12|演算法7-3|6$\quad$while (<font color="#f00">(data[j-h]>target) && (j>0)</font>)|6$\quad$while (<font color="#08f">(j-h>0) && (data[j-h]>target)</font>) (j>0==>j-h>0、兩條件互換) |
| 7-21|-6|<font color="#f00">9~10</font>行(…|<font color="#08f">8~9</font>行(…|
| 7-24|7|它不必<font color="#f00">該</font>次分割...|它不必<font color="#08f">與該</font>次分割... |
| 7-30|1|破壞<font color="#f00">值相同</font>資料的...|破壞<font color="#08f">相同數值</font>資料的... |
| 7-30|-4|<font color="#f00">8</font>為排序數列中第六位|<font color="#08f">9</font>為排序數列中第六位|
| 7-37|2|進行<font color="#f00">十</font>位數字依序計數|進行<font color="#08f">百</font>位數字依序計數|
| 7-38|演算法7-10|1$\quad$q = <font color="#f00">0</font>;|1$\quad$q = <font color="#08f">data[0]</font>; |
| 7-48|演算法7-13|3$\quad$if(<font color="#f00">y<=z</font>)|3$\quad$if(<font color="#08f">b<=c</font>)|
| 7-48|演算法7-13|4$\quad$else if(<font color="#f00">x<=z</font>)|4$\quad$else if(<font color="#08f">a<=c</font>)|
### 第一章
| $頁數$ | 行數或區段 | 錯誤 | 更正 |
| --- | --- | -------- |--|
| 1-10 | -3 | 請看程式 <font color="#f00">1-2</font>。 | 請看程式 <font color="#08f">1-2</font>。(字體請用 Courier New)|
 <br> | <br>  |
| 15$\qquad\qquad$for (0 $\le$ k $\le$ <font color="#08f">7</font>)|