![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
bdss58
这个作者很懒,什么都没留下…
展开
-
红黑树演进
看这个 https://www.cs.princeton.edu/~rs/talks/LLRB/RedBlack.pdf,茫然。看这个 https://zhuanlan.zhihu.com/p/340419231 拾人牙慧。原创 2021-01-10 13:30:23 · 349 阅读 · 0 评论 -
AVL平衡二叉树(删除操作)
AVL树的删除操作同这篇文章http://blog.csdn.net/bdss58/article/details/41788243里的插入操作相似,具体实现步骤参考这篇文章。两个步骤:1)按照BST树的删除操作方法,删除AVL树中的摸个节点2)“再平衡”“再平衡”的详细介绍请看http://blog.csdn.net/bdss58/article/details/41788243原创 2014-12-10 17:07:34 · 802 阅读 · 0 评论 -
Red-Black Tree红黑树
Red-Black Tree is a self-balancing Binary Search Tree (BST) where every node follows following rules.原创 2014-12-07 16:12:09 · 677 阅读 · 0 评论 -
用动态规划解决(maximum sum subarray and maximum product subarray)
一些问题从整体上看貌似无从下手,cho原创 2014-10-19 21:14:04 · 1255 阅读 · 2 评论 -
牛顿法求平分根(newton's method)
牛顿法又称牛顿迭代法。最近看machine learning中的线性回归(linear regression)中的梯度下降法(gradient descent)时候,我立刻回想起了学习C语言的时候课堂讲的牛顿迭代法求函数的零点。细想想这两者还是有一定联系的。他们都用到了导数,利用导数无限逼近最优解。数学啊数学,万物之宗也!好了,废话不多说,言归正传。上面的函数是任意的,我们的任务是原创 2014-12-15 19:40:44 · 1372 阅读 · 0 评论 -
最短路径图算法(shortest path dijkstra)
算法1)新建一个集合sptSet(shortest path tree set)用来记录最短路径树上的节点。初始状态sptSet为空2)给图中的节点赋上一个距离值。初始状态所有节点的距离值为INFINITE.将源节点的距离值赋值为0.3)while sptSet没有包含所有节点:...a)从图中距离值最小的节点u放入集合sptSet中...b)更新节点u的所有邻居节点的距离值。原创 2014-10-13 11:42:18 · 4213 阅读 · 0 评论 -
MapReduce实例
本文参考http://michaelnielsen.org/blog/page/19/ 从MapReduce的经典例子—单词统计开始。 一个MapReduce job的输入是一个(input_key, input_value)这样的键值对集合。键值对集合可以使用python的dictionary数据类型来表示。在单词统计例子中,input_key是文件名,input_value是文件内容。...原创 2016-05-02 00:09:27 · 554 阅读 · 0 评论 -
堆排序解决 top k 问题
import timeimport heapqimport randomdef gen_large_arr(n): arr = [i for i in range(n)] random.shuffle(arr) return arr# find top n item from bigarray using liner searchdef liner_search(big原创 2017-01-08 13:20:42 · 964 阅读 · 0 评论 -
二叉树的序列化和反序列化
二叉树的序列化同遍历一样,有先序、后序和中序之分。这里使用先序遍历去序列化二叉树。这样的一个一个二叉树,先序遍历的结果是:124536 1 | ---|--- | | --2-- --3 | | | 4 5 6为了序列化,现将空节点使用符号“#“代替,那么先序遍历的结果就是:124...原创 2018-03-19 21:24:46 · 703 阅读 · 0 评论 -
LRU缓存算法
注:本文使用golang语言表述。LRU(least recently used)是一个缓存剔除策略算法,在缓存容量不足的时候,将最不常用的一个或多个缓存相剔除,腾出空间以便后续缓存使用。实现一个LRU cacheLRU cache可以使用两个数据结构来表示。一个hashtable,用来存储需要存储的缓存项,这样,get/set操作可以在O(1)时间复杂度下完成。一个d...原创 2018-06-13 11:43:46 · 455 阅读 · 0 评论 -
AVL平衡二叉树
AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for all nodes.原创 2014-12-07 16:11:22 · 748 阅读 · 0 评论 -
k均值聚类(K-Means Clustering)
k means clustring algorithm was developed by原创 2014-11-08 22:47:07 · 1567 阅读 · 0 评论 -
动态规划(DP dynamic programming)
>>>>>>>原创 2014-10-13 11:30:50 · 567 阅读 · 0 评论 -
全排列(permutations)
算法设计时候,递归技巧对于新手来时不是很容易掌握。求一串数字的全排列就可以用递归技巧写出程序。例如,[1,2,3] 有下列排列:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], 和 [3,2,1].原创 2014-10-04 17:18:11 · 687 阅读 · 0 评论 -
分治算法(Divide-and-Conquer Algorithm)一
。。原创 2014-11-19 16:08:48 · 1449 阅读 · 0 评论 -
深度优先搜索Depth-first search (DFS) for undirected graphs
Depth-first search (DFS) for undirected graphsDepth-first search, or DFS, is a way to traverse the graph. Initially it allows visiting vertices of the graph only, but there are hundreds of algorithm原创 2014-11-02 21:56:25 · 1071 阅读 · 0 评论 -
最大和子数组与最大积子数组(Largest Sum Contiguous Subarray & Maximum Product Subarray)
》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》原创 2014-10-16 13:25:41 · 762 阅读 · 0 评论 -
二叉堆(Binary heap)
Binary heapThere are several types of heaps, but in the current article we are going to discuss the binary heap. For short, let's call it just "heap". It is used to implement priority queue ADT原创 2014-11-03 16:32:51 · 2538 阅读 · 0 评论 -
二叉堆的实现
用c实现小顶堆,堆元素类型问int。原创 2014-11-04 16:03:36 · 777 阅读 · 0 评论 -
分治算法(Divide-and-Conquer Algorithm)二
用分治算法解决“最近点对”问题原创 2014-11-23 20:39:21 · 1772 阅读 · 0 评论 -
字符串查找算法kmp
kmp原创 2014-12-15 22:08:19 · 745 阅读 · 0 评论 -
k临近算法(k nearest neighbors)
k nearest neighbor algorithm is very simple原创 2014-11-08 22:02:35 · 2441 阅读 · 0 评论 -
快速排序(quick-sort)
今儿闲着没事儿看了一眼c++primer原创 2014-10-06 18:01:00 · 683 阅读 · 0 评论