Skip to content

Commit

Permalink
feat: 基础算法增加图
Browse files Browse the repository at this point in the history
  • Loading branch information
luzhipeng committed May 29, 2019
1 parent 20de403 commit a86a1eb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions thinkings/basic-data-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,32 @@ database engine

### 字典树(前缀树)

#### immutable 与 字典树

immutable的底层就是share + tree. 这样看的话,其实和字典树是一致的。

相关算法:

- [208.implement-trie-prefix-tree](../problems/208.implement-trie-prefix-tree.md)
##
前面讲的数据结构都可以看成是图的特例。 前面提到了二叉树完全可以实现其他树结构,
其实有向图也完全可以实现无向图和混合图,因此有向图的研究一直是重点考察对象。

## 图的表示方法

- 邻接矩阵(常见)

空间复杂度O(n^2),n为顶点个数。

优点:

1. 直观,简单。

2. 适用于稠密图

3. 判断两个顶点是否连接,获取入度和出度以及更新度数,时间复杂度都是O(1)

- 关联矩阵
- 邻接表

1. 适用于稀疏图

0 comments on commit a86a1eb

Please sign in to comment.