java chapter3.ppt


文档分类:中学教育 | 页数:约89页 举报非法文档有奖
1/89
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/89
文档列表 文档介绍
Data Structure
Software College Northeastern University
Chapter 3
Linked Lists
Data Structure
Software College Northeastern University
Overview
Linked Lists
Programming mon Error
Doubly Linked Lists
Circularly Linked Lists
examples
Cursors Implementation of Linked Lists
Data Structure
Software College Northeastern University
Variable-length arrays?
Direct access to element (By indexing)
Array size is fixed-length
-To expand them, you create a new, longer array, and copy the contents of the old array into the new array
This is used by function realloc() in C
This is slow!
Linear time Insertion/Removal due to shift elements
due to contiguous storage in memory
Half of the list needs to be moved for either operations
Data Structure
Software College Northeastern University
Variable-length arrays?
Solution:
-The list is not need to store contiguously.
-Attach a pointer to each item in the array, which points to the next item.
-provides the ability to add or remove the items anywhere in the list in constant time
This is a linked list
Linked lists are unbounded
(maximum number of items limited only by memory)
Data Structure
Software College Northeastern University
The Linked List data structure
[0]
[1]
[2]
array
A
B
C
Array
Head
A
B
C
Linked list
An data item plus its pointer is called a node
A node contains data item and one or more links.
- The link is a reference to a node.
- The link of last node is set to NULL
a “head” which is a pointer to the first node in the
linked list
node
Data Structure
Software College Northeastern University
以线性表中第一个数据元素的存储地址作为线性表的地址,称作线性表的头指针。
头结点
a1 a2 …... an ^
头指针
头指针
有时为了操作方便,在第一个结点之前虚加一个“头结点”,以指向头结点的指针为链表的头指针。
空指针
线性表为空表时,
头结点的指针域为空

Data Structure
Software College Northeastern University
ZHAO
QIAN
SUN
LI
ZHOU
WU
ZHENG
WANG
^
H
43
13
1
NULL
37
7
19
25
Data Item
Links
LI
QIAN
SUN
WANG
WU
ZHAO
ZHENG
ZHOU
Address
1
7
13
19
25
31
37
43

java chapter3 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数89
  • 收藏数0 收藏
  • 顶次数0
  • 上传人lyd13607
  • 文件大小1.72 MB
  • 时间2018-01-16