zoukankan      html  css  js  c++  java
  • 20172307 2017-2018-2 《程序设计与数据结构》第8周学习总结

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

    教材学习内容总结

    1.多态性可以理解为多种形式。多态性引用能够随时间变化指向不同类型的对象。
    2.通过继承来实现多态性。原理是用类名声明一个引用变量时,这个引用变量可以指向该类的任何一个对象,而且也能引用通过继承与它声明的类型有关的任何类的对象。
    3.通过接口来实现多态性。原理和继承类似,接口名也可以用做声明对象引用变量的类型。
    4.排序:

    • 选择性排序:扫描整个数列找到最小值,把最小值与第一个位置的数调换位置,以此类推,第二小的和第二个位置的数调换
    • 插入法排序: 从第二个数开始与前面的数依次与前面的数比较,再插入前面的数中。

    5.搜索:

    • 线性搜索:从第一个端点开始,以线性的方式依次搜索。
    • 二分搜索:对有序数列进行二分法的搜索。

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

    • 问题1:做自测题10.4发生错误。具体题目:
         MusicPlayer mplayer = new MusicPlayer();
         CDPlayer cdplayer = new CDPlayer();
         mplayer = cdplayer;
    

    其中MusicPlayer类是CDPlayer类的父类。

    • 问题1解决方案:通过后面的参考答案,了解到这句是合法的,CDPlayer作为MusicPlayer的子类,也是一种MusicPlayer。相反的cdplayer不能被mplayer赋值,因为mplayer不一定是cdplayer。
    • 问题2:对多态性这个概念还是不太理解,对它到底是一个属性还是什么东西不太清楚。
    • 问题2解决方案:通过在网上资料的查找,算是有了一个更加清晰的认识:多态性指的是不同的类的对象可以对同一信息进行不同的反应,信息指的是调用方法。
      参考至(Java多态性理解)

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

    • 问题1:在做PP10.5时直接调用Sorting里面的方法,结果显示数组不支持该方法

    • 问题1解决方案:原因是因为DVDCollection没有实现Compare接口。当初对Compare接口如何实现不太懂,这次之后算是有所了解了

    代码托管

    上周考试错题总结

    • We compare sorting algorithms by examining
      A . the number of instructions executed by the sorting algorithm
      B . the number of instructions in the algorithm itself (its length)
      C . the types of loops used in the sorting algorithm
      D . the amount of memory space required by the algorithm
      E . whether the resulting array is completely sorted or only partially sorted
      正确:A 错误:D
      解析:比较算法时,效率是基本标准。一般来说一种排序算法的执行的比较操作比另一种算法更多,则前者便是效率更低的算法。
    • Polymorphism is achieved by
      A . overloading
      B . overriding
      C . embedding
      D . abstraction
      E . encapsulation
      正确:B 错误:D
      解析:实现多态性的方式应该是方法的重写。
    • Comparing the amount of memory required by selection sort and insertion sort, what can one say?
      A . Selection sort requires more additional memory than insertion sort
      B . Insertion sort requires more additional memory than selection sort
      C . Both methods require about as much additional memory as the data they are sorting
      D . Neither method requires additional memory
      E . None of the above
      正确:D 错误:A
      解析:选择排序和插入排序都不需要额外的内存空间。
    • Can a program exhibit polymorphism if it only implements early binding?
      A . Yes, because one form of polymorphism is overloading
      B . No, because without late binding polymorphism cannot be supported
      C . Yes, because so long as the programs uses inheritance and/or interfaces it supports polymorphism
      D . Yes, because early binding has nothing to do with polymorphism
      E . none of the above
      正确:A 错误:B
      解析:利用重载,可以实现只有前绑定的情况下实现多态性。

    结对及互评

    • 本周结对学习情况

      • 20172311
      • 本周和晓海同学一起完成结对项目,晓海同学帮助我了很多,像是博客的排版什么的也给我很多建议,在这里对他表示由衷的感谢。希望接下来的合作能更加愉快。
    • 上周博客互评情况

    其他

    本周的学习有些慢了吧,拖了很久才把第十章学完,下一周要加快进度。

    学习进度条

    代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
    目标 5000行 30篇 400小时
    第一周 200/200 2/2 20/20
    第二周 300/500 1/3 18/38
    第三周 500/1000 1/4 22/60
    第四周 300/1300 1/5 30/90
    第五周 700/ 2000 1/6 30/120
    第六周 792/2792 1/7 30/150
    第七周 823/3559 1/8 30/180
    第八周 774/4333 3/9 30/ 210

    参考资料

  • 相关阅读:
    JavaScript 数组中 length 属性【每日一段代码100】
    连续往上滚动jquery代码
    关于<img>标签的几个问题
    前端页面制作常见问题及解决方案
    JavaScript random() 方法【每日一段代码96】
    JavaScript split() 方法【每日一段代码99】
    JavaScript boolean 对象检查逻辑值【每日一段代码94】
    CSS 属性总结
    JavaScript max() 方法【每日一段代码97】
    JavaScript sort() 方法数组排序文字【每日一段代码92】
  • 原文地址:https://www.cnblogs.com/20172307hyt/p/8981755.html
Copyright © 2011-2022 走看看