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

本文总结了《程序设计与数据结构》课程的学习内容,包括集合、列表、队列、堆栈、树和图等基本概念及其应用。通过具体实例介绍了队列的使用方法,并探讨了树的实现方式。此外,还分享了选择排序的链表实现方法,以及递归函数的应用案例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;
        }

代码托管

1333086-20180523205514717-1735043512.jpg
1333086-20180523205521620-1874572141.jpg

上周考试错题总结

  • 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/2002/220/20
第二周300/5001/318/38
第三周500/10001/422/60
第四周300/13001/530/90
第五周700/ 20001/630/120
第六周792/27921/730/150
第七周823/35591/830/180
第八周774/43333/930/ 210
第九周426/47592/1130/ 240

参考资料

转载于:https://www.cnblogs.com/20172307hyt/p/9064929.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值