算法競賽實戰筆記

梁博 等

  • 出版商: 電子工業
  • 出版日期: 2024-01-01
  • 售價: $468
  • 貴賓價: 9.5$445
  • 語言: 簡體中文
  • 頁數: 244
  • ISBN: 7121470128
  • ISBN-13: 9787121470127
  • 立即出貨

買這商品的人也買了...

相關主題

商品描述

近年來,隨著互聯網和人工智能的廣泛應用,算法作為其關鍵技術的內核,備受學校和企業的重視,算法競賽更成為算法領域的一顆明珠。本書依托編著者多年算法競賽的教學積累,全方位介紹了競賽中常用的算法及近年來算法競賽領域最新的研究成果,基於算法競賽中廣泛使用的在線評測網站——洛谷,著重介紹線性數據結構,基礎算法,搜索算法,動態規劃等方面的知識。本書適合對算法競賽感興趣的青少年閱讀,也可作為相關領域教師、電腦專業學生的參考用書。

目錄大綱

第 0 章 一些不那麽常識的常識 ············································································.1
0.1 本地編程環境的配置··············································································.1
0.1.1 在 Windows 系統上安裝使用 Dev C++···············································.1
0.1.2 在 MacOS 系統上安裝 Xcode ··························································.4
0.2 在線評測系統—洛谷···········································································.7
0.2.1 註冊洛谷 ···················································································.8
0.2.2 提交題目 ···················································································.9
0.2.3 團隊管理 ···················································································11
第 1 章 線性數據結構 ························································································15
1.1 數據結構·····························································································15
1.1.1 數據結構的定義 ··········································································15
1.1.2 數據結構的運算 ··········································································17
1.1.3 線性數據結構 ·············································································17
1.2 棧······································································································18
1.2.1 棧的定義 ···················································································18
1.2.2 棧的作用 ···················································································20
1.2.3 棧的固定數組實現 ·······································································21
1.2.4 STL 中的棧 ················································································24
1.2.5 括號匹配問題 ·············································································26
1.2.6 前綴、中綴、後綴表達式 ······························································30
1.2.7 後綴表達式的計算 ·······································································32
1.2.8 中綴表達式轉換為後綴表達式 ························································36
1.2.9 中綴表達式的計算 ·······································································41
1.3 隊列···································································································43
1.3.1 隊列的定義 ················································································44
1.3.2 隊列的作用 ················································································46
1.3.3 隊列的固定數組實現 ····································································46
1.3.4 STL 中的隊列 ·············································································47
1.3.5 基數排序(Radix Sorting)·····························································50
1.3.6 結構體的構造函數 ·······································································56
1.3.7 隊列的應用 ················································································59
1.4 前綴和·······························································································.66
1.4.1 前綴和的引入 ············································································.66
1.4.2 一維數組前綴和 ·········································································.66
1.5 動態數組····························································································.75
1.5.1 動態數組 vector ··········································································.75
1.5.2 STL 中的動態數組 ······································································.75
1.5.3 vector 的缺點 ·············································································.76
1.5.4 vector 與迭代器 iterator·································································.76
1.5.5 vector 與 C++11 ··········································································.78
1.5.6 vector 的實現原理 ·······································································.80
1.6 樹·····································································································.82
1.6.1 樹的相關概念 ············································································.82
1.6.2 樹的性質 ··················································································.84
1.6.3 特殊的樹—二叉樹 ···································································.84
1.6.4 完全二叉樹的性質 ······································································.85
1.6.5 樹的存儲方式 ············································································.86
1.6.6 樹的遍歷 ··················································································.89
1.6.7 知二求一 ··················································································101
1.6.8 樹的寬度優先遍歷 ······································································105
1.7 本章習題····························································································105
第 2 章 基礎算法 ·····························································································106
2.1 貪心算法····························································································106
2.1.1 貪心算法的概念 ·········································································106
2.1.2 基礎貪心問題舉例 ······································································107
2.1.3 線段覆蓋問題 ············································································111
2.2 高精度計算·························································································113
2.2.1 C++語言中的數據類型·································································113
2.2.2 高精度加法 ···············································································115
2.2.3 高精度減法 ···············································································118
2.2.4 高精度乘法 ···············································································121
2.2.5 高精度除法取餘數 ······································································126
2.3 歸並排序····························································································129
2.3.1 歸並 ························································································130
2.3.2 歸並排序的時間復雜度分析 ··························································134
2.3.3 歸並排序的應用 ·········································································135
2.4 快速排序··························································································.143
2.4.1 快速排序的思想················································································.143
2.4.2 快速排序的時間復雜度分析 ························································.146
2.5 STL ································································································.151
2.5.1 algorithm 頭文件中的函數 ···························································.152
2.5.2 容器 ······················································································.156
2.6 本章習題··························································································.159
第 3 章 搜索算法 ···························································································.160
3.1 深度優先搜索····················································································.160
3.1.1 迷宮尋路與烤雞問題 ·································································.160
3.1.2 全排列問題與回溯 ····································································.166
3.1.3 洪水填充(Flood Fill)算法·························································.168
3.1.4 八皇後問題與剪枝 ····································································.171
3.1.5 數獨問題 ················································································.174
3.1.6 剪枝 ······················································································.177
3.2 寬度優先搜索····················································································.181
3.2.1 找眼鏡 ···················································································.181
3.2.2 馬的遍歷 ················································································.182
3.2.3 01 迷宮···················································································.185
3.2.4 八數碼問題 ·············································································.188
3.3 本章習題··························································································.190
第 4 章 動態規劃 ···························································································.191
4.1 動態規劃入門····················································································.191
4.1.1 斐波那契數列 ··········································································.191
4.1.2 數字三角形 ·············································································.193
4.1.3 遞推+填表···············································································.195
4.2 動態規劃解題步驟··············································································.199
4.2.1 分解子問題 ·············································································.199
4.2.2 確定狀態 ················································································.200
4.2.3 狀態轉移 ················································································.200
4.2.4 動態規劃能解決的問題的特點 ·····················································.201
4.3 線性動態規劃····················································································.201
4.3.1 最長上升子序列問題(LIS)·······················································.201
4.3.2 最長公共子序列問題(LCS)······················································.209
4.4 背包類動態規劃·················································································.213
4.4.1 01 背包問題···············································································213
4.4.2 多重背包問題 ············································································225
4.4.3 完全背包問題 ············································································228
4.4.4 分組背包問題 ············································································231
4.4.5 二維費用背包問題 ······································································241
4.5 區間動態規劃與多維動態規劃·············································································243
4.5.1 區間動態規劃 ············································································243
4.5.2 多維動態規劃 ············································································248
4.6 本章習題····························································································256