Topological Sort

1 Definition In computer science, a topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertx v, u comes before v in the ordering. It sounds pretty academic, but I am sure you are using topological sort unconsciously every single day. 2 Application Many real world situations can be modeled as a graph with directed edges where some events must occur before others. Then a topological sort gives an order in which to perform these events, for instance: ...

五月 22, 2022 · 2 分钟 · 943 字

关于分布式系统唯一ID的探究

最近我需要为运行的分布式系统某部分模块构造系统唯一的ID, 而 ID 需要是数字的形式,并应该尽量的短。不得不说,这是一个有趣的问题 1 若干实现策略 查阅完相关的资料,发现为分布式系统生成唯一 ID 方法挺多的,例如: ...

五月 23, 2017 · 4 分钟 · 1616 字

爬虫高效去重之布隆过滤器

笔者最近思考如何编写高效的爬虫; 而在编写高效爬虫的时候,有一个必需解决的问题就是: url 的去重,即如何判别 url 是否已经被爬取,如果被爬取,那就不要重复爬取。 ...

四月 9, 2017 · 3 分钟 · 1345 字

归并排序算法改进

最近笔者在阅读《算法》,重温经典数据结构和算法,毕竟一直以来的说法是程序就是数据结构+算法归并算法所需的时间和N*logN成正比,所以可以用归并算法处理数百万甚至更大规模的数据。 但是归并算法也是存在不足之处的,需要额外的空间来完成排序,而且空间和N的 大小也是成正比的 1 优化 《算法》中有提到可以通过一些细致的修改实现大幅度缩短归并排序的运行时间 ...

三月 1, 2017 · 3 分钟 · 1311 字