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

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

教材学习内容总结

  • 第十三章
    1.集合:集合是一种对象,有些集合是异构的,有些是同构的。
    2.列表:可以实现插入,添加,删除等功能。
    3.队列:使用先进先出的存取方式。
    4.堆栈:使用后进先出的存取方式。
    5.树:由一个根节点和构成参差结构的多个节点组成。
    6.图:在一个图中,一个节点到一个另一个节点的连接称为边,连接一个图内个节点的边数一般没有限制。
    7.泛型:Java中的API中的类定义为泛型,是指一个集合所管理的对象类型要在实例化该集合对象时才确定。

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

  • 问题1:书上对队列的使用方法没有介绍,对这方面不太理解。
  • 问题1解决方案:通过查阅网上的资料,了解到使用队列要通过java.util.Queue接口,通过里面的方法来实现
    例子:
import java.util.Queue;
import java.util.LinkedList;
public class TestQueue {
    public static void main(String[] args) {
        Queue<String> queue = new LinkedList<String>();
        queue.offer("Hello");
        queue.offer("World!");
        queue.offer("你好!");
        System.out.println(queue.size());
        String str;
        while((str=queue.poll())!=null){
            System.out.print(str);
        }
        System.out.println();
        System.out.println(queue.size());
    }
}

参考至:(java中的队列)

  • 问题二:对树的概念和实现方式不太理解
  • 解决方式:通过查阅网上的资料,了解到了树的实现方式。
    参考至:(java实现树

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

  • 在编写PP13.1的时候不知道应该怎么样用链表的形式实现选择排序。
  • 在参考书上的选择排序的代码后想到其实用链表的形式和数组的形式其实是是一样的,同样的实现方法,由一个暂时的存放点,比较时放入。具体代码如下:
 public void sort() {
        NumberNode min;
        NumberNode temp;
        NumberNode numNode = list;

        while (numNode != null) {
            min = numNode;
            NumberNode current = min.next;
            while (current != null) {
                if (current.num < min.num) {
                    min = current;
                }
                current = current.next;
            }
            temp = min.next;
            min.next = numNode.next;
            numNode.next = temp;

            numNode = numNode.next;
        }

代码托管


上周考试错题总结

  • The following method should return true if the int parameter is even and either positive or 0, and false otherwise. Which set of code should you use to replace ... so that the method works appropriately?
    public boolean question3(int x) { ... }:
    A . if (x = = 0) return true;else if (x < 0) return false;else return question3(x - 1);
    B . if (x = = 0) return false;else if (x < 0) return true;else return question3(x - 1);
    C . if (x = = 0) return true;else if (x < 0) return false;else return question3(x - 2);
    D . if (x = = 0) return false;else if (x < 0) return true;else return question3(x - 2);
    E . return(x = = 0);
    错误:A;正确:C
    解析:判断数是否为偶数,在递归时每次减二就可以实现。
  • Aside from writing recursive methods, another way that recursion is often used is to define:
    A . words in English
    B . mathematical functions
    C . rules and laws
    D . child classes of a parent class in object-oriented programming
    E . recursion is used in all of the above
    错误:E;正确:B
    解析:递归还可以用于实现数学公式。
  • An infinite loop and an infinite recursion:
    A . are different because it is impossible to detect the latter, while it's quite easy to detect the former
    B . both continue to repeat indefinitely
    C . both will be caught by the compiler
    D . both will be caught by the Java Virtual Machine during execution
    E . none of the above
    错误:A;正确:B
    解析:无限循环和无限递归都会没有限制的重复。

结对及互评

其他

继续努力。。。

学习进度条

代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
目标 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
第九周 426/4759 2/11 30/ 240

参考资料

posted @ 2018-05-20 22:25  做作业  阅读(179)  评论(2编辑  收藏  举报