20172330 2017-2018-1 《程序设计与数据结构》第十周学习总结
教材学习内容总结
本周的学习内容为集合
集合
- 对象具有定义良好的接口,从而成为一种实现集合的完善体制。
- 动态数据结构的大小规模随需要增长和收缩。
- 通过引用和保存对象引用来实现一个链表的管理。
- 通过自习操作对象引用,可以实现插入和删除操作。
- 动态链表有许多不同的实现。
- 队列是一种以先进先出方式管理数据的线性数据结构。
- 堆栈是一种以后进后出的方式管理数据的线性数据结构。
教材学习中的问题和解决过程
- 问题1:树和图作为非线性数据结构的代表,它们的相同点和不同点
- 问题1解决方案:如书上所说,Java的核心库java.io提供了全面的IO接口。包括:文件读写、标准设备输出等。Java中IO是以流为基础进行输入输出的,所有数据被串行化写入输出流,或者从输入流读入。
下附Java中IO流的所有类
IO流还有许多东西需要去慢慢学习,对于很多方面都有概括的。 -
- 问题2: 递归与迭代的比较
问题2解决方案:对于某些问题,递归是最精炼和适当的解法,但对于其他的问题,递归则不如迭代解法直观。
递归中一定有迭代,但是迭代中不一定有递归,大部分可以相互转换.能用迭代的不用递归,递归调用函数,浪费空间,并且递归太深容易造成堆栈的溢出.
代码调试中的问题和解决过程
- 问题1:在做pp11.1的时候,无论我输入多长的字符串他都显示超过
- 问题1解决方案:当时反复检查代码觉得并没有问题啊,然后使用了代码调试一步步进行下去发现由于在if语句后加了一个;,导致throw语句一直能够进行,所以才会一直出现显示超出的提示。
代码托管
上周考试错题总结
Why is the following method one which has infinite recursion?
public int infiniteRecursion(int n)
{
if (n > 0) return infiniteRecursion(n) + 1;
else return 0;
}
A Because there is no base case
B Because the base case will never be true
C Because the recursive call does not move the parameter closer to the base case
D Because the recursive call moves the problem further away from the base case
E None of the above, there is no infinite recursion in this method
分析:如果输入大于零的数,那么将不会进入else语句,也就说一直在大于零的情况下进行递归的循环A recursive algorithm is superior to an iterative algorithm along which of the following criteria?
A The recursive algorithm is easier to debug
B The recursive algorithm is computationally more efficient
C The recursive algorithm is more elegant
D The recursive algorithm requires less memory to execute
E all of the above
分析:当时我理解的应该是a递归算法更易于调试,但是答案给的是c。问题3:The difference between direct and indirect recursion is
A direct recursion occurs when a method invokes itself; indirect recursion occurs when there is an intervening method
B indirect recursion occurs when a method invokes itself; direct recursion occurs when there is an intervening method
C direct recursion only occurs with methods declared to be private; indirect recursion can occur with methods declared to be private, protected, or public
D indirect recursion only occurs with methods declared to be private; direct recursion can occur with methods declared to be private, protected, or public
E none of the above
分析:A选项的意思是:当一个方法调用自己时,就会发生直接递归;间接递归发生在有干预方法的时候。直接递归意味着一个方法直接调用自己,而不使用中间方法。当在原始方法再次被调用之前有一个或多个中间方法时,就会发生间接递归。问题4:The following method correctly multiplies two ints so long as both are non-negative:
public int mpy(int a, int b)
{
return (b > 0) ? a + mpy(a, b-1) : 0;
}
A true
B false
分析:乘法只是重复加法,所以重复的加a,b倍,就是两个数的乘积。
结对及互评
点评模板:
- 博客中值得学习的或问题:
- 严域俊同学在进行异常和错误的区别时进行了详细的描述并配了图
- 同时在根据自己代码中出现的问题又一次进行了查询和解答。
- 代码中值得学习的或问题:
- 这周我两就四则运算的最后结合部分进行了修改,但还是存在很多问题,我两也在不断地学习与探索过程中学到了很多,也希望能够按时完成四则运算吧。
- commit依旧很详细,有条理性。
点评过的同学博客和代码
- 本周结对学习情况
- 20172333
- 结对学习内容
- 学习第十一和十二章pp项目。
- 学习异常和递归的具体内容
- 对于IO操作的共同探讨
- 继续完善四则运算的的项目。
其他(感悟、思考等,可选)
终于这本书学习完了,nice啊。
学习进度条
代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | 重要成长 | |
---|---|---|---|---|
目标 | 5000行 | 30篇 | 400小时 | |
第一周 | 180/180 | 2/2 | 20/25 | |
第二周 | 312/414 | 2/4 | 20/45 | |
第三周 | 557/971 | 1/5 | 25/70 | |
第四周 | 1217/2242 | 2/7 | 44/114 | |
第五周 | 734/2976 | 1/8 | 24/138 | |
第六周 | 523/3509 | 1/9 | 20/158 | |
第七周 | 697/4206 | 1/10 | 24/182 | |
第八周 | 1118/5324 | 3/13 | 30/212 | |
第九周 | 656/5980 | 2/15 | 20/232 | |
第十周 | 656/5980 | 2/15 | 20/232 |
计划学习时间:20小时
实际学习时间:20小时
改进情况:
这周对于课后练习做的没有那么吃力,但还是存在一些对于类的编写的问题,希望继续加油。