P1 数据结构: 课程导论
Abstract data types(ADTs)
Arrays
Linked List
stack
queue
Tree
Graph
1)Logical view
2)operations
3)cost at operations
4)Implementation
P2 抽象数据类型(ADT)
List as abstracy data type
List - store a given number of elements at a given data type
- write /modify element at a position
- read element at a position
Are you talking about arrays?
it has the functions
List - empty list has size 0
- insert
- remove
- count
- read /modify element at a position
- apecity data-type
数组的大小是有限的
P3 链表基本介绍(Linked List)
typedef struct Node {
int data; //4 bytes
Node* next; //4 bytes
} Node;
head node 头节点的地址可以让我们访问完整的链表
last node 最后一个节点中的地址为 0 / NULL
P4 数组vs链表
which one is better?
the answer is not certain
1.访问某个元素所需成本: 数组更好
2.内存需求: 数组需要更大的内存空间来储存可能添加的元素, 链表则需要为指针分配内存空间
数组所需空间连续, 可能需要重新盛名一个新数组并复制一个数组过去
3.插入或者删除元素的成本
4.谁更好用: 链表更容易出现错误