20172323 2017-2018-2 《程序设计与数据结构》第十周学习总结

教材学习内容总结

本章主要学习第十三章-集合

  • 集合是一个对象,其目的是保存和组织基本数据类型或其他对象。
  • 集合的同构及异构
  • 抽象数据类型(ADT)是由数据和在该数据上所实施的具体操作构成的集合
  • 对象具有定义良好的接口,从而成为一种实现集合的完善机制
  • 动态数据结构用链来实现,利用对象引用作为连接对象间的链,建立适用于各种情况的数据结构,且它的大小规模随需要增长和收缩

  • 通过保存和更新对象引用来实现一个链表的管理
  • 队列是一种以先进先出方式管理数据的线性数据结构
  • 堆栈是一种以后进先出方式管理数据的线性数据结构
  • 是一种以层次结构组织数据的非线性数据结构
  • 是非线性数据结构,但没有初始入口点,使用常见的边来连接节点。边是双向的,在一个有向图中,每条边只有特定的方向。
  • 泛型保证了集合中对象类型的兼容性

教材学习中的问题和解决过程

  • 问题1:对于抽象数据类型(ADT)的理解不够,看了定义之后感觉确实挺抽象的。
  • 问题1解决方案:在网络上我找到了关于ADT的另一种定义

    一个数学模型以及定义在该模型上的一组操作。

还是有些宽泛,再换一种说法,抽象数据类型可以使我们更容易描述现实世界,例如用线性表描述学生成绩表,用树或图描述遗传关系。并且,使用它的人可以只关心它的逻辑特征,不需要了解它的存储方式。也就是书上提到的

ADT如何保存数据和执行方法的细节与其概念分离开了

  • 问题2:对象为什么特别适于实现抽象数据类型
  • 问题2解决方案:抽象数据类型是一个包含数据和施加在这些数据上的操作的集合。对象实现上就是将变量和相关的方法封装在一起的实体。对象隐藏了ADT背后的实现细节,并且将接口和底层的实现相分离,使得实现发生变化后并不影响接口。
  • 问题3:ArrayList类和LinkedList类的区别和优缺点?
  • 问题3解决方案

    1.ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构。
    2.对于随机访问get和set,ArrayList觉得优于LinkedList,因为LinkedList要移动指针。
    3.对于新增和删除操作add和remove,LinedList比较占优势,因为ArrayList要移动数据。

代码调试中的问题和解决过程

  • 问题1:课堂实验中,要求完成链表的插入和删除
  • 问题1解决方案
  • 书上给出了如何在链表中插入一个节点或删除一个节点的思路,即将要插入位置前一个节点的指针“切断”,重新将指针引向要插入的节点上再从插入的节点上引出指针指向下一个节点。
  • 但是有一个困难的地方在于,如何在指定的节点位置插入一个节点?因为链表似乎并没有专门的方法用数字来表示某一节点的位置,所以我想到了运用for循环来找到要插入的位置,int n = 0; n < index - 2; n++设置一个值n,当n小于index - 2时,由指针移向下一节点,又因为插入的地方相当于是当前第index个节点与第index-1个节点之间的空格,所以设置为index - 2。如果当前位置为空,就直接插入到当前位置。
  • 问题2:
  • 问题2解决方案:
  • ...

代码托管

上周考试错题总结

  • 错题1:A Java program can handle an exception in several different ways. Which of the following is not a way that a Java program could handle an exception?
    A . ignore the exception
    B . handle the exception where it arose using try and catch statements
    C . propagate the exception to another method where it can be handled (将异常传递到可以处理的方法中)
    D . throw the exception to a pre-defined Exception class to be handled(将异常抛出到一个预先定义的异常类)
    E . all of the above are ways that a Java program could handle an exception

  • 解析异常不会被抛出到异常类中


  • 错题2:A finally clause will execute
    A . only if the try statement that precedes it does not throw an exception
    B . only if the try statement that precedes it throws an exception that is caught
    C . only if the try statement that precedes it throws an exception that is not caught
    D . only if the try statement that precedes it throws an exception, whether it is caught or not
    E . in any circumstance
  • 解析无论try语句块正常退出或由于抛出异常而退出,都将执行finally子句

  • 错题3:NullPointerException and ArithmeticException are both derived from which class?
    A . Error
    B . Exception
    C . RuntimeException
    D . IllegalAccessException
    E . CheckedException
  • 解析还是没有仔细看书啊

  • 错题4:Which of the following is not true of the RuntimeExceptions class?
    A . All RuntimeExceptions throw checked exceptions
    B . All RuntimeExceptions are Throwable objects
    C . RuntimeException has child classes ArithmeticException and NullPointerException
    D . RuntimeException objects are not Error objects
    E . All of the above are true
  • 解析Java中唯一的不可检测异常是RuntimeException类的对象或该类的后代类对象。所有其他的异常都是可检测异常。对于可检测异常,如果发生异常的方法不捕获和处理这个异常,则必须在该方法定义的声明头中包含throws子句

  • 错题5:Character streams manage
    A . byte-sized data (byte-sized数据)
    B . binary data(二进制数据)
    C . Unicode characters(Unicode字符)
    D . ASCII characters(ASCII字符)
    E . compressed data(压缩数据)
  • 解析字符流处理的单元为2个字节的Unicode字符,字节流可用于任何类型的对象,包括二进制对象

  • 错题6:System.err is a(n)
    A . input stream
    B . GUI dialog box that indicates when an error has arisen
    C . object
    D . Error subclass
    E . RuntimeException subclass
  • 解析System类中有三种对象引用变量(in、out、err),分别代表三种标准I/O流。

  • 错题7:A method that uses the Scanner class to obtain input does not require either catching or throwing an IOException.(使用Scanner类获取输入的方法不需要捕捉或抛出IOException。) This is because
    A . the Scanner class does not call upon any classes that throw checked exceptions(Scanner类不调用抛出检查异常的任何类)
    B . the Scanner class' methods call input methods in try statements and catch IOExceptions so that they are handled directly in the Scanner class(Scanner类的方法在try语句中调用输入方法并捕获ioexception,以便它们直接在Scanner类中处理。)
    C . the Scanner class uses JOptionPane dialog boxes instead of java.io classes so that it does not have to deal with IOExceptions(Scanner类使用的是JOptionPane对话框,而不是java.io类,这样它就不需要处理ioexception)
    D . the Scanner class overrides the class IOException making it an unchecked exception(Scanner类覆盖类IOException,使其成为不可检测异常)
    E . none of the above, methods do require handling IOException even if thrown by a method in a Scanner class (以上都是错误的,在Scanner类中抛出的IOException同样需要处理)
  • 解析Scanner类里自带try-catch语句,可以处理异常

结对及互评

其他

本周的学习相对比较轻松,但有几个概念需要重点把握,我在问题中已经略详细地记录了一下几个概念。到目前为止这本教材的学习应该是告一段落了,我只能给我的学习打70分,特别是中间一段时期学习任务有点重时,我稍微有些倦怠,导致中间一段时间的学习有些跟不上步伐,希望借着以后的时间好好补补,争取能赶上。

学习进度条

代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
目标 5000行 30篇 400小时
第一周 117/117 1/1 19/19
第二周 289/406 1/2 21/40
第三周 403/809 2/4 22/62
第四周 1783/2592 1/5 35/97
第五周 770/3362 1/6 25/122
第六周 734/4096 1/7 25/147
第七周 687 / 4783 1/8 25/172
第八周 824/5607 2/10 30/202
第九周 764/6371 2/12 30/432
第十周 540/6911 2/14 20/452
  • 计划学习时间:20小时

  • 实际学习时间:20小时

  • 改进情况:教材阅读比较仔细了吧,也因此遇到了很多问题,也同时学会了在网上查阅资料解决疑难。

参考资料

猜你喜欢

转载自www.cnblogs.com/Lewandodoski/p/9064622.html
今日推荐