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小时
- 改进状况:课下有必定复习,对二叉排序树理解有必定提高,但对最近所讲树相关内容应用时吃力。
参考资料