MengBridgeCourse 中文版

第 8 章 链表、包、栈与效率

| 关于   英文版   «  7.9. 单元 7 实验 3 占位符   ::   目录   ::   8.2. 链表包  »

8.1. 链表(内存)

8.1.1. 目标

完成本模块后,学生将能够:

  • 理解节点链接链的特性及其用法

  • 实现链接链及相关方法

  • 遍历链接链

  • 追踪链接链方法的执行过程

  • 比较基于数组和链接链的实现

  • 练习链接链操作

8.1.1.1. 致谢

本页面部分正文和图像最初由斯坦福大学的 Nick Parlante 撰写,经作者许可使用:" Pointers and Memory"(版权 1998-2000),斯坦福计算机科学教育图书馆。

8.1.2. 交互式:节点链的入门介绍 [10:51]

Follow Along and Engage

跟随视频学习,并参考 LinkedChain 类

package linkedchain;

public class LinkedChain {

   private Node head; // Reference to first node
   private int numberOfEntries;

   public static void main(String[] args) {

      LinkedChain chain = new LinkedChain();
      chain.add(10);
      chain.add(-2);
      chain.add(57);
   }

   public LinkedChain() {
      head = null;
      numberOfEntries = 0;
   } // end default constructor

   public void add(int newEntry) {
      // Add to beginning of chain:
      Node newNode = new Node(newEntry);
      newNode.next = head; // Make new node reference rest of chain
      head = newNode; // New node is at beginning of chain
      numberOfEntries++;
   } // end add

   private class Node {
      private int data;
      private Node next; // Link to next node

      private Node(int dataPortion) {
         this(dataPortion, null);
      } // end constructor

      private Node(int dataPortion, Node nextNode) {
         data = dataPortion;
         next = nextNode;
      } // end constructor
   } // end Node
}

8.1.3. 检查点 1

8.1.4. 交互式:在可视器的演示 [11:31]

Follow Along and Engage

下载与视频对应的幻灯片。观看视频时,在幻灯片上做笔记,并亲自练习绘制图表!

Video Slides 8.1.3-LinkedChainCode.pdf

8.1.5. 检查点

8.1.6. Contains() 方法动画 [5:14]

Follow Along and Engage

下载与视频对应的幻灯片。观看视频时,在幻灯片上做笔记,并亲自练习绘制图表!

Video Slides 8.1.4-LinkedChainContains.pdf

   «  7.9. 单元 7 实验 3 占位符   ::   目录   ::   8.2. 链表包  »

关闭窗口