`
izuoyan
  • 浏览: 8916973 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

一些有意思的算法代码

 
阅读更多

Keith Schwarz是一个斯坦福大学计算机科学系的讲师。他对编程充满了热情。他的主页上他自己正在实现各种各样的有意思的算法和数据结构,http://www.keithschwarz.com/interesting/, 目前这个网页上有88个(见下面的列表),但这位大哥要干135个,你可以看看他的To-Do List

从这个列表上,我们可以看到,他从去年7月份就在自己实现这些东西了,我把他实现的这些算法转过来,

  • 另一方面我希望这个事可以影响到一些正在学习编程的人。看看别人是怎么学习编程的,希望对你有借鉴作用。
Name Link Date Added Language Description
Binomial Heap (link) 7‑24‑2010 C++ An implementation of a binomial heap data structure for use as a priority queue.
Bounded Priority Queue (link) 7‑24‑2010 C++ An implementation of a priority queue with a fixed upper limit to its size..
Matrix (link) 7‑24‑2010 C++ A collection of classes for manipulating matrices.
VList (link) 8‑16‑2010 Java An implementation of the List abstraction backed by a VList.
Function Wrapper (link) 8‑16‑2010 C++ A C++ wrapper class around unary functions.
String (link) 8‑17‑2010 C++ An implementation of a string abstraction that uses the small string optimization.

nstream (link) 8‑31‑2010 C++ An stream class that sends and receives data over a network.
Snake (link) 8‑31‑2010 C++ An implementation of the game Snake with a rudimentary AI.
Mergesort (link) 9‑14‑2010 C++ An implementation of the mergesort algorithm.
Next Permutation (link) 10‑6‑2010 C++ An implementation of the next_permutation STL algorithm.
Interval Heap (link) 10‑17‑2010 Java An implementation of a double-ended priority queue using an interval heap.
Linear-Time Selection (link) 10‑18‑2010 C++ A deterministic, linear-time selection algorithm using the median-of-medians algorithm.
Heapsort (link) 10‑18‑2010 C++ An implementation of the heapsort algorithm.
Union-Find (link) 10‑19‑2010 Java An implementation of a disjoint-set data structure using a disjoint set forest.
Radix Sort (link) 10‑19‑2010 C++ An implementation of the radix sort algorithm.
Rational (link) 10‑23‑2010 C++ A data structure representing a rational number.
DPLL (link) 10‑23‑2010 Haskell An implementation of the DPLL algorithm for solving CNF-SAT.
Smoothsort (link) 10‑27‑2010 C++ An implementation of the smoothsort algorithm, an adaptive heapsort variant.
Extendible Array (link) 10‑28‑2010 Java A dynamic array class with O(1) worst-case runtime lookup and append.
In-Place Merge (link) 10‑29‑2010 C++ An implementation of a merge algorithm that runs in-place.
Random Shuffle (link) 10‑29‑2010 C++ An algorithm for generating a random permutation of a set of elements.
Random Sample (link) 10‑29‑2010 C++ An O(n) time, O(1) space algorithm for randomly choosing k elements out of a stream with uniform probability.
Natural Mergesort (link) 10‑30‑2010 C++ An implementation of natural mergesort, an adaptive variant of mergesort.
Interpolation Search (link) 10‑31‑2010 C++ An implementation of the interpolation search algorithm.
Introsort (link) 10‑31‑2010 C++ An implementation of the introsort algorithm, a fast hybrid of quicksort, heapsort, andinsertion sort.
Hashed Array Tree (link) 11‑3‑2010 Java An implementation of a dynamic array backed by a hashed array tree.
Recurrence Solver (link) 11‑13‑2010 C++ A fast algorithm for generating terms of a sequence defined by a linear recurrence relation.
Fibonacci Heap (link) 11‑15‑2010 Java An implementation of a priority queue backed by a Fibonacci heap.
Dijkstra’s Algorithm (link) 11‑16‑2010 Java An implementation of Dijkstra’s algorithm for single-source shortest paths.
Prim’s Algorithm (link) 11‑17‑2010 Java An implementation of Prim’s algorithm for computing minimum spanning trees.
Kruskal’s Algorithm (link) 11‑17‑2010 Java An implementation of Kruskal’s algorithm for computing minimum spanning trees.
Majority Element (link) 11‑17‑2010 C++ A fast, linear-time algorithm for finding the majority element of a data set.
Haar Transform (link) 11‑17‑2010 C++ A set of functions to decompose a sequence of values into a sum of Haar wavelets.
Argmax (link) 11‑19‑2010 C++ A pair of functions to compute the arg min or max of a function on some range.
Derivative (link) 11‑19‑2010 C++ A function object that approximates the derivative of a function.
Levenshtein Distance (link) 11‑19‑2010 C++ An algorithm for computing the Levenshtein distance between two sequences.
Skiplist (link) 11‑20‑2010 C++ An implementation of a skip list, a randomized data structure for maintaining a sorted collection.
van Emde Boas Tree (link) 11‑26‑2010 C++ An implementation of a sorted associative array backed by a van Emde Boas tree.
Cuckoo HashMap (link) 11‑27‑2010 Java An implementation of a hash table using cuckoo hashing.
Needleman-Wunsch Algorithm (link) 11‑28‑2010 C++ An implementation of the Needleman-Wunsch algorithm for optimal string alignment.
Treap (link) 11‑28‑2010 C++ An implementation of a sorted associative array backed by a treap.
Floyd-Warshall Algorithm (link) 12‑10‑2010 Java An implementation of the Floyd-Warshall algorithm for all-pairs shortest paths in a graph.
Power Iteration (link) 12‑10‑2010 C++ An implementation of the power iteration algorithm for finding dominant eigenvectors.
Edmonds’s Matching Algorithm (link) 12‑15‑2010 Java An implementation of Edmonds’s matching algorithm for finding maximum matchings in undirected graphs.
Kosaraju’s Algorithm (link) 12‑15‑2010 Java An implementation of Kosaraju’s algorithm algorithm for finding strongly connected components of a directed graph.
2-SAT (link) 12‑15‑2010 Java A linear-time algorithm for solving 2-SAT.
Bellman-Ford Algorithm (link) 12‑17‑2010 Java An implementation of the Bellman-Ford algorithm for single-source shortest paths.
Topological Sort (link) 12‑17‑2010 Java An algorithm for computing a topological sort of a directed acyclic graph.
Graham Scan (link) 12‑19‑2010 C++ An implementation of the Graham scan for finding convex hulls in 2D space.
Bipartite Testing (link) 12‑19‑2010 Java A linear-time algorithm for checking whether a directed graph is bipartite.
Johnson’s Algorithm (link) 12‑19‑2010 Java An implementation of Johnson’s algorithm for all-pairs shortest paths.
Strassen Algorithm (link) 12‑20‑2010 C++ An implementation of the Strassen algorithm for fast matrix multiplication.
Cartesian Tree Sort (link) 12‑21‑2010 C++ An implementation of Cartesian tree sort, an adaptive, out-of-place heapsort variant.
Ford-Fulkerson Algorithm (link) 12‑21‑2010 Java An implementation of the Ford-Fulkerson maximum-flow algorithm.
Scaling Ford-Fulkerson (link) 12‑22‑2010 Java An modification of the Ford-Fulkerson maximum-flow algorithm that uses scaling to achieve polynomial time..
Splay Tree (link) 12‑27‑2010 C++ An implementation of a sorted associative array backed by a splay tree.
Ternary Search Tree (link) 12‑28‑2010 C++ An implementation of a sorted set of strings backed by a ternary search tree.
Ring Buffer (link) 12‑30‑2010 Java An implementation of a FIFO queue using a ring buffer.
AVL Tree (link) 12‑30‑2010 C++ A sorted associative container backed by an AVL tree.
Rabin-Karp Algorithm (link) 1‑1‑2011 C++ An implementation of the Rabin-Karp algorithm for string matching.
RPN Evaluator (link) 1‑18‑2011 C++ / strain A library to tokenize and evaluate simple arithmetic expressions in reverse Polish notation.
Shunting-Yard Algorithm (link) 1‑18‑2011 C++ / strain An implementation of Dijkstra’s shunting-yard algorithm for converting infix expressions to reverse-Polish notation.
Skew Binomial Heap (link) 1‑20‑2011 C++ An implementation of a priority queue backed by a skew binomial heap.
2/3 Heap (link) 3‑1‑2011 C++ An implementation of a priority queue whose branching factor alternates at different levels to maximize performance.
Zeckendorf Logarithm (link) 3‑10‑2011 C++ An algorithm based on Zeckendorf representations that efficiently computes logarithms.
Factoradic Permutations (link) 3‑17‑2011 C++ A set of algorithms for generating permutations using the factoradic number system.
Binary Cyclic Subsets (link) 3‑20‑2011 C++ A set of algorithms for generating subsets in lexicographical order using binary numbers and cyclic shifts.
Fibonacci Iterator (link) 3‑22‑2011 C++ An STL-style iterator for iterating over the Fibonacci numbers.
Fibonacci Search (link) 3‑22‑2011 C++ An implementation of the Fibonacci search algorithm.
Euclid’s Algorithm (link) 4‑18‑2011 Haskell An implementation of Euclid’s algorithm and applications to continued fractions and the extended Euclidean algorithm.
Find Duplicate (link) 4‑18‑2011 Python An algorithm to find a repeated element in an array using Floyd’s cycle-finding algorithm.
Permutation Generator (link) 4‑19‑2011 Python A generator for producing all permutations of a list of elements.
Matrix Find (link) 4‑19‑2011 Python A solution to the classic interview question of searching a sorted matrix for a particular value.
Binary GCD (link) 4‑23‑2011 Scheme An implementation of the binary GCD algorithm for computing greatest common divisors of nonnegative integers.
Knuth-Morris-Pratt Algorithm (link) 5‑3‑2011 Python An implementation of the Knuth-Morris-Pratt algorithm for fast string matching.
Kadane’s Algorithm (link) 5‑7‑2011 C++ An implementation of Kadane’s algorithm for solving the maximum-weight subarray problem.
Karatsuba’s Algorithm (link) 8‑15‑2011 Python An implementation of Karatsuba’s algorithm for fast integer multiplication.
Min-Stack (link) 8‑15‑2011 C++ An implementation of a LIFO stack that supports O(1) push, pop, and find-minimum.
Random Bag (link) 8‑15‑2011 Python A data structure that supports insertion and removal of a uniformly-random element.
Min-Queue (link) 8‑15‑2011 C++ An implementation of a FIFO queue that supports O(1) push, pop, and find-minimum.
Lights-Out Solver (link) 8‑29‑2011 C++ A solver for the game Lights Out using Gaussian elimination over GF(2).
Maximum Single-Sell Profit (link) 11‑9‑2011 Python Four algorithms for the maximum single-sell profit problem, each showing off a different algorithmic technique.
Generalized Kadane’s Algorithm (link) 11‑10‑2011 C++ A generalization of Kadane’s algorithm for solving the maximum subarray problem subject to a length restriction.
Longest Range (link) 11‑19‑2011 Java An algorithm for solving the longest contiguous range problem.
Egyptian Fractions (link) 11‑20‑2011 Python An implementation of the greedy algorithm for finding Egyptian fractions.
LL(1) Parser Generator (link) 11‑21‑2011 Java An LL(1) parser generator.
LR(0) Parser Generator (link) 11‑23‑2011 Java An LR(0) parser generator.
Word Ladders (link) 11‑27‑2011 JavaScript A program for finding word ladders between two words.
分享到:
评论

相关推荐

    C#有意思的算法源码:百钱百鸡算法

    摘要:C#源码,算法相关,百钱百鸡 一个有意思的C#算法源码:百钱百鸡算法的实例源代码,公鸡5元一只,母鸡3元一只,小鸡3"+"\r"+"只一元,用100元买100只鸡,如果公鸡、母鸡和小鸡的总钱数加起来为100,/计算小鸡的...

    VC经典数据算法代码.rar_经典C算法

    VC经典数据算法代码 几个有意思的算法,初学算法有益,经典,经典

    好用的算法的代码

    很有意思,驱动里用的

    值得你看的C++27个趣味程序

    涉及经典算法,新颖独特,这其中包含了八皇后游戏,日历的编排,情侣专用“心”,子随父姓,智者生存,模拟抛硬币所得正面的频率图等好玩趣味性强的程序。网上关于c++的程序较少,所以本人将自己搜罗出来的资料上传...

    实验室笔记::smiling_face_with_heart-eyes:有趣的想法&有意思灵感&小算法实验室,犄角旮旯乱七八糟代码杂货铺,新奇好玩都在这里

    这个仓库主要是记录一些有趣有意思的东西,以源码为主,每一个源码基本上都会对应一篇文章说明,可以文章我在的或者仓库查看。 :hot_beverage:实验室 :lollipop:剑指优惠算法译文 :hourglass_not_done:小算法 ...

    编程算法练习--没事的时候练练

    练习一下,算法不管什么时候都是非常重要的吧!呵呵,没事的时候做做也是很有意思的!!

    C#百钱百鸡算法

    一个有意思的C#算法源码:百钱百鸡算法的实例源代码,公鸡5元一只,母鸡3元一只,小鸡3"+" "+"只一元,用100元买100只鸡,如果公鸡、母鸡和小鸡的总钱数加起来为100,/计算小鸡的个数,最后显示运行结果。

    LZARI压缩算法

    这个一个在我硬盘上躺了4年的代码,前不久拿出来做项目用了,发现了一些问题,经过修改该可以正常使用了; 可以压缩解压缩代码,原有代码有个bug 很有意思在某一个固定字节时在VC下会出现错误;在C++Builder下会...

    QQ农场分析+代码+VC++.rar

    这东西是以前觉得QQ农场比较有意思的时候写的,后来还让我同学帮忙分析分析数据, 结果后来太忙了,就一直荒废着,一直荒废到现在连QQ农场都快遗忘了 , 现在将我的分析与源代码 (VC++ 6.0) 发出来,有兴趣可以拿去...

    详解用python实现简单的遗传算法

    今天整理之前写的代码,发现在做数模期间写的用python实现的遗传算法,感觉还是挺有意思的,就拿出来分享一下。 首先遗传算法是一种优化算法,通过模拟基因的优胜劣汰,进行计算(具体的算法思路什么的就不赘述了)...

    LSB算法实现信息隐藏

    信息安全课的一个实验作业,要求采用LSB算法实现BMP图像中的信息隐藏及提取,写完后感觉这个算法还是蛮有意思滴~压缩包内附上实验报告,仅供各位参考~

    BIRCH聚类算法

    有意思的是簇中心、簇半径、簇直径以及两簇之间的距离D0到D3都可以由CF来计算,比如 簇直径 簇间距离,这里的N,LS和SS是指两簇合并后大簇的N,LS和SS。所谓两簇合并只需要两个对应的CF相加那可 CF1 + CF2 = (N1 +...

    acm和leetcode难度-leetcode:leetcode算法分析和代码实现

    如果碰巧你看到了这些解题思路和算法代码, 并且觉得老王的题解有意思或有帮助, 可以给老王点个赞或者打个赏啥的, 老王就更开心啦 ^o^ 以下列表, 每日更新↓ ID 解法链接 标题 难度 标签 1 两数之和 [Two Sum] ★☆☆...

    欧拉公式求圆周率的matlab代码-shuaOJ:naiveOnlineJudgesolutions愉快地刷各种OJ(摸了)

    欧拉公式求圆周率的matlab代码 shuaOJ wlh的各种刷题平台记录 现在才做别人大一就开始做的事,...可能会选一些有意思的不那么水的不是用来炫技的题放上来 Advent Of Code 比较偏向业务逻辑和基础数据结构,较少涉及算法

    内核阅读心得.pdf

    这段时间在看《Linux内核源代码情景分析》,顺便写了一些感悟。 。 读内核源代码是一件很有意思的事。它像一条线,把操作系统,编译原理,C语言, 数据结构与算法,计算机体系结构等等计算机的基础课程串起来。 我看...

    BP神经网络的Matlab实现——人工智能算法.pdf

    BP神经⽹络的Matlab实现——⼈⼯智能算法 这⼏天在各⼤媒体上接触到了⼈⼯智能机器学习,觉得很有意思,于是开始⼊门最简单的机器算法——神经⽹络训练算法(Neural Network Training);以前⼀直觉得机器学习很⾼深...

    MD5加密算法

    MD5加密算法VB源代码 日期:2008-02-05 看着这个办法还挺有意思的,可以试试 直接调用就可以了 '使用例子msgbox md5("加密的字符串") Private Const BITS_TO_A_BYTE = 8 Private Const BYTES_TO_A_WORD = 4 ...

    Android代码-ViewExplosion

    于是我对源代码进行了一些重构,将爆炸流程和粒子运动分离。 对于源码,大家可以参考以下链接 链接1 链接2 上面两套代码,其实结构都是一样的,但是实现的效果不同(其实就是粒子运动的算法不同)。 本篇文章,将给...

Global site tag (gtag.js) - Google Analytics