20182302 2019-2020-1 《數據結構與面向對象程序設計》第10周學習總結
教材學習內容總結
- 圖:頂點(vertice)和邊(edge)構成。
鄰接的(adjacent):圖中的兩個頂點之間有一條連通邊。
鄰居:鄰接頂點。
自循環(環):連通一個頂點及其自身的邊。
路徑:由一個頂點到達另外一個頂點。
路徑長度:路徑邊的條數(頂點數 - 1)。
環路:一種首頂點和末頂點相同且沒有重邊的路徑。沒有環路則是無環的(acyclic)。
- 按照度數進行排序
第一種先對第一個進行染色,再找不鄰接的進行染色
第三步重複第二步,直至全部點染色
得出結論,相同顏色考試在同一時間舉行不會衝突
2,5的度數爲5(2和5都可排在前面)
- 廣度優先遍歷——使用一個隊列和一個無序列表來實現,隊列用於管理遍歷,無序列表用於存儲遍歷結果。
第一步:起始頂點進入隊列,標記爲已訪問。
第二步:從隊列中取出起始頂點加入無序列表的末端,讓與該頂點相連的還未被標記爲已訪問的頂點加入隊列中,把它們都標記爲已訪問。
第三步:重複第二步的操做,每次取出隊列中的首個頂點加入無序列表,直至隊列爲空。
- 深度優先遍歷——使用一個棧和一個無序列表來實現,棧的做用與廣度優先遍歷中隊列的做用相同。
第一步:起始頂點進入棧。
第二步:從棧中取出起始頂點加入無序列表的末端,標記爲已訪問,讓與該頂點相連的頂點加入棧中。
第三步:重複第二步的操做,每次取出棧頂元素加入無序列表,把頂點標記爲已訪問,直至棧爲空。
- 無向圖
無向圖是一種邊爲無序結點對的圖
若是圖中的兩個頂點之間有一條連通邊,則稱兩個頂點是鄰接的
連通一個頂點及其自身的邊稱爲自循環
對有n個頂點的無向圖,要使該圖爲徹底的,要有n(n-1)/2條邊(此處假設沒有自循環)
路徑長度是該路徑中邊的條數
若是無向圖中任意兩個頂點之間都存在一條路徑,則認爲這個無向圖是連通的
環路是一種首末頂點相同且沒有重邊的路徑
有向圖
有向圖是一種邊爲有序頂點對的圖。
教材學習中的問題和解決過程
(01) ListUDG是鄰接表對應的結構體。
mVexNum是頂點數,mEdgNum是邊數;mVexs則是保存頂點信息的一維數組。html
(02) VNode是鄰接表頂點對應的結構體。
data是頂點所包含的數據,而firstEdge是該頂點所包含鏈表的表頭指針。node
(03) ENode是鄰接表頂點所包含的鏈表的節點對應的結構體。
ivex是該節點所對應的頂點在vexs中的索引,而nextEdge是指向下一個節點的git
- 問題2:addEdge方法裏運用到的幾個方法getIndex、indexIsValid分別是什麼意思
- 問題2解決方案:由於無向圖的實現是由一個頂點列表和鄰接矩陣組合而成的,因此若是要在兩個頂點之間添加一條邊,首先須要在頂點列表中找到這兩個頂點,getIndex就是這樣一個方法,用於定位正確的索引。indexIsValid則是用於判斷索引值是否合法,若是合法的話就把鄰接矩陣內兩個頂點之間對應的值改成true。另外一方面,頂點列表的索引值能夠用於鄰接矩陣,譬如頂點列表索引值爲一的位置的元素也就是鄰接矩陣第一行第一個或者第一列第一個表示的值。因此代碼實現時在這裏能夠直接寫adjMatrix[index1][index2] = true,adjMartix[index2][index1] = true。
代碼調試中的問題和解決過程
上週考試錯題總結
- D Which of the following is not an operation on a stack?
A .push
B .pop
C .peek
D .dequeue
E .all of the above are operations on a stack
- 出列操做是隊列操做。
- When one type of object contains a link to another object of the same type, the object is sometimes called __________ .
A .circular
B .recursive
C .self-referential
D .a stack
E .a queue
- 自引用對象是指同一類型的另外一個對象。
D The definition of a binary search tree is an extension of the definition of a ______________.
A .stack
B .queue
C .list
D .binary tree數組
B The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order ______.
A .n
B .log n
C .n log n
D .None of the above數據結構
B In removing an element from a binary search tree, another node must be demoted to replace the node being removed.
A .True
B .Flaseless
- B The balance restriction on a red/black tree is somewhat less strict than that for AVL trees. However, in both cases, the find operation is order n.
A .True
B .Flase
- C A minheap stores its smallest element at the ________ of the binary tree.
A .leaf
B .internal node
C .root
D .sibling
- C Typically, in heap implementations, we keep track of the position of the last node or, more precisely, the last leaf in the tree.
A .root
B .internal node
C .leaf
D .tree
- A Though not a queue at all, a minheap provides an efficient implementation of a _____________.
A .Priority queue
B .Circular queue
C .Deque
D .None of the above
- B The addElement operation for both the linked and array implementations is O(__________).
A .n
B .log n
C .n log n
D .None of the above
B Since a heap is a binary search tree, there is only one correct location for the insertion of a new node, and that is either the next open position from the left at level h or the first position on the left at level h+1 if level h is full.
A .True
B .Flaseide
結對及互評
點評:
- 博客中值得學習的或問題:
- 代碼中值得學習的或問題:
- 本週代碼總量較上多
- 對本週知識點進行及時複習,上課認真聽講記錄
- 代碼編寫時規範性有待提升
- 基於評分標準,我給本博客打分:13分。得分狀況以下:正確使用Markdown語法(加1分)模板中的要素齊全(加1分)教材學習中的問題和解決過程(加2分)代碼調試中的問題和解決過程(加2分)本週有效代碼超過300分行(加2分)感想,體會不假大空(加1分)進度條中記錄學習時間與改進狀況(加1分)結對學習狀況真實可信(加1分)有動手寫新代碼(加1分)點評認真,能指出博客和代碼中的問題的(加1分)
點評過的同窗博客和代碼
其餘(感悟、思考等,可選)
對圖樹結構使用時學習
學習進度條
目標 |
6000行 |
25篇 |
300小時 |
|
第一週 |
143/143 |
2/2 |
7/7 |
學會對虛擬機進行基礎設置,學會git程序簡單使用 |
第二週 |
388/531 |
3/5 |
10 /17 |
學會部分基礎編碼,掌握循環格式話輸出等內容 |
第四周 |
807/1338 |
1/6 |
17/34 |
學會運用IDEA編寫和測試代碼 |
第五週 |
1289/2096 |
2/8 |
17/51 |
學會運用IDEA編寫和測試代碼 |
第六週 |
1005/3101 |
2/10 |
19/70 |
學會繼承封裝多態 |
第七週 |
2240/5341 |
2/12 |
15/85 |
學習棧,隊相關操做 |
第八週 |
404/5745 |
2/14 |
17/102 |
學習查找,排列相關操做 |
第九周 |
2855/7600 |
3/17 |
12/114 |
學習二叉排序樹相關操做 |
第十週 |
1527/9127 |
3/20 |
14/128 |
學習有關樹,圖結構相關操做 |
嘗試一下記錄「計劃學習時間」和「實際學習時間」,到期末看看能不能改進本身的計劃能力。這個工做學習中很重要,也頗有用。
耗時估計的公式:Y=X+X/N ,Y=X-X/N,訓練次數多了,X、Y就接近了。測試
參考:軟件工程軟件的估計爲何這麼難,軟件工程 估計方法this
- 計劃學習時間:20小時
- 實際學習時間:14小時
- 改進狀況:課下有必定複習,對二叉排序樹理解有必定提高,但對最近所講樹相關內容應用時吃力。
參考資料