Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1800334

Browse files
committed
更新文档
1 parent 70356b0 commit 1800334

File tree

3 files changed

+105
-4
lines changed

3 files changed

+105
-4
lines changed

README.zh-CN.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# JavaScript 算法与数据结构
22

3-
TypeScript 版本
3+
## TypeScript 版本
44

5-
参考
6-
7-
- https://github.com/loiane/javascript-datastructures-algorithms
5+
参考 https://github.com/loiane/javascript-datastructures-algorithms
86

97
[![CI](https://github.com/trekhleb/javascript-algorithms/workflows/CI/badge.svg)](https://github.com/trekhleb/javascript-algorithms/actions?query=workflow%3ACI+branch%3Amaster)
108
[![codecov](https://codecov.io/gh/trekhleb/javascript-algorithms/branch/master/graph/badge.svg)](https://codecov.io/gh/trekhleb/javascript-algorithms)
@@ -290,6 +288,7 @@ npm test -- 'playground'
290288

291289
### 数组排序算法的复杂性
292290

291+
<<<<<<< HEAD
293292
| 名称 | 最优 | 平均 | 最坏 | 内存 | 稳定 | 备注 |
294293
| ------------ | :------: | :------------: | :----------: | :----: | :--: | ---------------------------------------------- |
295294
| **冒泡排序** | n | n^2 | n^2 | 1 | Yes | |
@@ -303,3 +302,29 @@ npm test -- 'playground'
303302
| **基数排序** | n \* k | n \* k | n \* k | n + k | Yes | k - 最长 key 的升序 |
304303

305304
> ℹ️ A few more [projects](https://trekhleb.dev/projects/) and [articles](https://trekhleb.dev/blog/) about JavaScript and algorithms on [trekhleb.dev](https://trekhleb.dev)
305+
=======
306+
| 名称 | 最优 | 平均 | 最坏 | 内存 | 稳定 | 备注 |
307+
| --------------------- | :-------: | :-------: | :-----------: | :-------: | :-------: | --------------------- |
308+
| **冒泡排序** | n | n^2 | n^2 | 1 | Yes | |
309+
| **插入排序** | n | n^2 | n^2 | 1 | Yes | |
310+
| **选择排序** | n^2 | n^2 | n^2 | 1 | No | |
311+
| **堆排序** | n log(n) | n log(n) | n log(n) | 1 | No | |
312+
| **归并排序** | n log(n) | n log(n) | n log(n) | n | Yes | |
313+
| **快速排序** | n log(n) | n log(n) | n^2 | log(n) | No | 在 in-place 版本下,内存复杂度通常是 O(log(n)) |
314+
| **希尔排序** | n log(n) | 取决于差距序列 | n (log(n))^2 | 1 | No | |
315+
| **计数排序** | n + r | n + r | n + r | n + r | Yes | r - 数组里最大的数 |
316+
| **基数排序** | n * k | n * k | n * k | n + k | Yes | k - 最长 key 的升序 |
317+
318+
## 扩展学习
319+
320+
* TypeScript 版本
321+
* 算法可视化
322+
323+
参考资料
324+
325+
* https://github.com/loiane/javascript-datastructures-algorithms
326+
* https://visualgo.net/zh
327+
* https://coolshell.cn/articles/4671.html
328+
* https://www.cs.usfca.edu/~galles/visualization/Algorithms.html
329+
* https://www.cs.usfca.edu/~galles/visualization/source.html
330+
>>>>>>> 5b541e4 (更新文档)

examples/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
- 求最大值、最小值
2020
- 验证是否为数组
2121

22+
迷宫生成算法 https://zhuanlan.zhihu.com/p/47395955
23+
https://bost.ocks.org/mike/algorithms/#maze-generation
24+
https://github.com/luobotang/maze
25+
https://bost.ocks.org/mike/
26+
27+
Java程序员3面小米,被俩算法题难倒,微软员工6分钟解决,真丢脸
28+
https://zhuanlan.zhihu.com/p/38850888
29+
30+
31+
为什么算法这么难? https://zhuanlan.zhihu.com/p/25101438
32+
33+
FreeCodeCamp 高级算法题 - 字符串排列 https://zhuanlan.zhihu.com/p/30567628
34+
https://zhuanlan.zhihu.com/p/27659059
35+
2236
Node.js大众点评爬虫 https://www.cnblogs.com/en-heng/p/5895207.html
2337

2438
- lz77 算法

stl/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# STL
2+
3+
STL 是“Standard Template Library”的缩写,中文译为“标准模板库”。STL 是 C++ 标准库的一部分,不用单独安装。
4+
5+
C++ 对模板(Template)支持得很好,STL 就是借助模板把常用的数据结构及其算法都实现了一遍,并且做到了数据结构和算法的分离。例如,vector 的底层为顺序表(数组),list 的底层为双向链表,deque 的底层为循环队列,set 的底层为红黑树,hash_set 的底层为哈希表。
6+
7+
STL 组件主要包括容器,迭代器、算法和仿函数。
8+
9+
js实现
10+
11+
使用 js 实现一套类似 C++的 STL 库。
12+
13+
参考
14+
15+
- [js-stl](https://github.com/cloudyan/js-stl)
16+
- [The JavaScript STL (Standard Template Library)](http://webreference.com/programming/javascript/gr/column13/index.html)
17+
- [Std Javascript Library](http://www.stdjs.com/)
18+
19+
## STL 见解
20+
21+
### 容器
22+
23+
容器即用来存储并管理某类对象的集合。例如鱼缸是用来盛放金鱼的容器。
24+
25+
每一种容器都有其优点和缺点。为满足程序的各种需求,STL 准备了多种容器类型,容器可以是 arrays 或是 linked lists,或者每个元素有特别的键值。
26+
27+
### 迭代器
28+
29+
迭代器用于在一个对象群集的元素上进行遍历动作。对象群集可能是容器,也可能是容器的一部分。
30+
31+
迭代器的主要用途是为容器提供一组很小的公共接口。利用这个接口,某项操作可以行进至群集内的下一个元素。
32+
33+
每种容器都提供了各自的迭代器。迭代器了解该容器的内部结构,所以能够正确行进。迭代器的接口和一般指针类似。
34+
35+
### 算法
36+
37+
算法用来处理群集内的元素,可以出于不同目的搜寻、排序、修改、使用那些元素。所有容器的迭代器都提供一致的接口,通过迭代器的协助,算法程序可以用于任意容器。
38+
39+
STL 的一个特性是将数据和操作分离。数据由容器类别加以管理,操作则由可定制的算法定义。迭代器在两者之间充当“粘合剂”,以使算法可以和容器交互运作。
40+
41+
STL 的另一个特性即组件可以针对任意型别运作。“标准模板库”这一名称即表示“可接受任意型别”的模板,并且这些型别均可执行必要操作。
42+
43+
在 STL 中,容器又分为**序列式容器****关联式容器**两大类,而迭代器的功能主要是遍历容器内全部或部分元素的对象。迭代器可划分为 5 种类属,这 5 种类属归属两种类型:**双向迭代器****随机存取迭代器**
44+
45+
SIL 中提供的算法包括搜寻、排序、复制、重新排序、修改、数值运算等。
46+
47+
仿函数
48+
49+
STL中大量运用了仿函数。仿函数具有泛型编程强大的威力,是纯粹抽象概念的例证。
50+
51+
STL基本结构
52+
53+
STL 是 C++ 通用库,由迭代器、算法、容器、仿函数、配接器和配置器(即内存配置器)组成。
54+
容器
55+
56+
STL 包含诸多容器类。容器类是可以包含其他对象的类,就像数组和队列堆栈等数据结构包含整数、小数、类等数据成员一样。STL 可以包含常见的向量类、链表类、双向队列类、集合类、图类等,每个类都是一种模板,这些模板可以包含各种类型的对象。
57+
58+
参考:
59+
60+
- http://c.biancheng.net/view/1436.html
61+
- https://github.com/CarpenterLee/JCFInternals/blob/master/markdown/0-Introduction.md
62+
- https://github.com/LukeLin/js-stl

0 commit comments

Comments
 (0)