算法分析入门系列(三) 动态规划算法

算法分析入门系列(三) 动态规划算法

作业排程问题

问题描述

Automobile factory with two assembly lines(汽车厂两条装配线)

– Each line has n stations: S1,1, . . . , S1,n and S2,1, . . . , S2,n(每条装

配线有n个工序站台)

– Corresponding stations S1, j and S2, j perform the same function

but can take different amounts of time a1, j and a2, j (每条装配线的

第j个站台的功能相同,但是效率不一致)

– Entry times e1 and e2 and exit times x1 and x2(上线和下线时间)

阅读更多
算法分析入门系列(四) 最短路径算法
算法分析入门系列(二) 分治算法
算法分析入门系列(一) 排序算法

算法分析入门系列(一) 排序算法

排序算法

main函数代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
public static void main(String[] args) {
int max = 10;
System.out.println("插入排序-------------------------------------");
int[] num = randomCreate(max);
printResult(num);
Long bt = System.nanoTime();
int[] temp1 = insertSort(num);
Long et = System.nanoTime();
System.out.println("排序用时:" + (et - bt + ""));
printResult(temp1);


System.out.println("合并排序-------------------------------------");
int[] temp4 = randomCreate(max);
printResult(temp4);
Long bt2 = System.nanoTime();
mergeSort(temp4);
Long et2 = System.nanoTime();
System.out.println("排序用时:" + (et2 - bt2 + ""));
printResult(temp4);


System.out.println("快速排序-------------------------------------");
int[] temp5 = randomCreate(max);
printResult(temp5);
Long bt3 = System.nanoTime();
quickSort(temp5, 0, temp5.length - 1, false);
Long et3 = System.nanoTime();
System.out.println("排序用时:" + (et3 - bt3 + ""));
printResult(temp5);

System.out.println("随机化快速排序--------------------------------");
int[] temp9 = randomCreate(max);
printResult(temp9);
Long bt7 = System.nanoTime();
quickSort(temp9, 0, temp9.length - 1, true);
Long et7 = System.nanoTime();
System.out.println("排序用时:" + (et2 - bt2 + ""));
printResult(temp9);


System.out.println("桶排序---------------------------------------");
int[] temp6 = randomCreate(max);
printResult(temp6);
Long bt4 = System.nanoTime();
temp6 = bucketSort(temp6, max);
Long et4 = System.nanoTime();
System.out.println("排序用时:" + (et4 - bt4 + ""));
printResult(temp6);

System.out.println("计数排序-------------------------------------");
int[] temp7 = randomCreate(max);
printResult(temp7);
Long bt5 = System.nanoTime();
temp7 = countSort(temp7);
Long et5 = System.nanoTime();
System.out.println("排序用时:" + (et5 - bt5 + ""));
printResult(temp7);

System.out.println("基数排序-------------------------------------");
int[] temp8 = randomCreate(max);
printResult(temp8);
Long bt6 = System.nanoTime();
radixSort(temp8, (max + "").length());
Long et6 = System.nanoTime();
System.out.println("排序用时:" + (et6 - bt6 + ""));
printResult(temp8);
System.out.println("---------------------------------------------");

}
阅读更多
快速提交git代码到多个托管平台
如何制作一个简单的网络爬虫?nodejs实现

如何制作一个简单的网络爬虫?nodejs实现

接下来有打算每半个月写一点东西,不然写东西的频率太低就会造成正反馈,产出越来越少了。

这段时间一共做了三个爬虫:

  • 爬取丁香园的疫情数据
  • 爬取联想的虚拟货币乐豆
  • 第三个跟第一个类似,不过工作量大一点
阅读更多
Shell脚本编程最简尝试
WuHan-nCoV-2019疫情数据接口
Neeto - 我所期待的MD编辑器

Neeto - 我所期待的MD编辑器

或许,这个简陋的项目更应该被称为Electron && JavaScript最佳实践

Neeto的起源

最初这个项目是基于Steve Kinney的 《Electron跨平台开发实战》 一书第三章的Fire Sale项目。这本书写的挺好,通俗易懂,并且比较有借鉴价值。本来的计划是抛开那本书重新构建Neeto的架构,但有些代码我也不想做重复工作,所以就没有另开一个工程。

阅读更多
Neeto - 为补全缺憾而生的Markdown编辑器