Posts

Showing posts from June, 2018

Python 学习小心得 001

最近花了2天时间学习了一下python。越发的觉得,整个编程语言的进程就是一部活活的进化史。看见了它拥有所有的编程语言都有的不变的筋骨,看见了它萃取他人之精华,也看见了它化繁为简自成一派的优势。 时代在进步,我为此感到了无比的欣喜。最近常常和身边的朋友说,长大真是一件好美妙的事情,可以看懂了以前看不懂的电影,理解了以前理解不了的书,听懂了以前听不懂的音乐,唯有一点,似乎对人的宽容和耐心比以前少了些,也许是发现,再好玩的人再有意思的人都有个终点,不如我自己好玩。哈哈哈哈。不过我也很清楚的明白,这是不好的,要像我的同事Alejandro学习,做一个耐心的,谦虚的,有责任感的,thoughtful的人。 As my principal: Do something good Do something meaningful Do something helpful 下面要记录下我在python里面的小感受。 1. 化繁为简,只用list代替了queue, stack, list, array. 所有的iteratable的操作都可以用list完成。 Python List Methods append()  - Add an element to the end of the list extend()  - Add all elements of a list to the another list insert()  - Insert an item at the defined index remove()  - Removes an item from the list pop()  - Removes and returns an element at the given index clear()  - Removes all items from the list index()  - Returns the index of the first matched item count()  - Returns the count of number of items passed as an

Topological Sort

What's topological sort? Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge uv, vertex u comes before v in the ordering.  Topological Sorting for a graph is not possible if the graph is not a DAG. 结果: 在DAG中,f or every directed edge uv, vertex u comes before v in the ordering. 它是对图中顶点的排序,保证在有向图中,每个节点的出现都是线性的有序的。 注意: 只有DAG能够拓扑排序。(什么是DAG? DAG 是没有回路的有向图。) 不能拓扑排序的条件: 有回路 有向 一个DAG的拓扑序可能有多个 拥有唯一拓扑序的条件: 排序算法: 统计每个点的入度  将每个入度为 0 的点放入队列(Queue)中作为起始节点  不断从队列中拿出一个点,去掉这个点的所有连边(指向其他点的边),其他点的相应的入度 - 1  一旦发现新的入度为 0 的点,丢回队列中 Question of Topological sort 求任意1个拓扑序 Topological Order  是否存在拓扑序(是否可以被拓扑排序)  是否存在环? 求所有的拓扑序  DFS backtracking 求是否存在且仅存在一个拓扑序 每次Queue中最多同时只有1个节点 拓展: 图的相关问题。 树:in  graph theory , a  tree  is an  undirected graph  in which any two  vertices  are connected by  exactly one   path . Every  acyclic   connected  graph is a tree, and vice versa.  任意两个顶

研究课题

1. 如何做好网站的SEO? 2. 如何scraping website?