Presentation is loading. Please wait.

Presentation is loading. Please wait.

JAVA 程式設計與資料結構 第十四章 Linked List. Introduction Linked List 的結構就是將物件排成一列, 有點像是 Array ,但是我們卻無法直接經 由 index 得到其中的物件 在 Linked List 中,每一個點我們稱之為 node ,第一個 node.

Similar presentations


Presentation on theme: "JAVA 程式設計與資料結構 第十四章 Linked List. Introduction Linked List 的結構就是將物件排成一列, 有點像是 Array ,但是我們卻無法直接經 由 index 得到其中的物件 在 Linked List 中,每一個點我們稱之為 node ,第一個 node."— Presentation transcript:

1 JAVA 程式設計與資料結構 第十四章 Linked List

2 Introduction Linked List 的結構就是將物件排成一列, 有點像是 Array ,但是我們卻無法直接經 由 index 得到其中的物件 在 Linked List 中,每一個點我們稱之為 node ,第一個 node 我們稱之為 head ,最後 一個 node 稱之為 tail 。 使用 next 來指位並指向之後的一個 node , 稱之為 link 或是 pointer 。如果是指向前一 個物件的 pointer 稱之為 previous 。

3 Singly Linked List Singly Linked List 指的是一個 Linked List 內的 node 只能夠指向後(前)一個 node (也就是單一方向),而最後的一個 node(tail) 指向一個空的物件 (null) 。

4 Insert 要在 Linked List 中加入一個 Node 的話,可 決定要加在 head 之前或是 tail 之後,亦或 是 current 指標之後皆可,端看設計者的 需要。

5 Search & Remove Search 的方式便是由頭搜尋到尾,其演算 速度為 O(n) Remove 的演算方式便是先 Search ,若是 找到的話便將其移除,其演算速度一樣 為 O(n) 。不過在移除某一個 Node 之後, 必須將其前後 Node 的 Pointer 相互連結, 以維持 Linked List 的連貫性。


Download ppt "JAVA 程式設計與資料結構 第十四章 Linked List. Introduction Linked List 的結構就是將物件排成一列, 有點像是 Array ,但是我們卻無法直接經 由 index 得到其中的物件 在 Linked List 中,每一個點我們稱之為 node ,第一個 node."

Similar presentations


Ads by Google