算法编程Algos Programming

不同算法的集合,用于编程比赛,如ACM ICPC。

算法按主题划分。大多数算法都可以从文件中按原样运行。每种算法都有一个参考问题,并对其时间和空间复杂度作了一些说明。

参考:https://github.com/ADJA/algos

算法列表List of algorithms

动态(优化,规划)编程Dynamic Programming

  • Convex Hull trick – Convex Hull trick is a geometry based dynamic programming modification.
  • Longest Increasing Sequence – Fast way to find longest increasing subsequence (subsequence in which each next element is greater than previous).
  • 凸壳(面,包,集)技巧–凸壳技巧是基于几何的动态规划修改。
  • 最长递增序列–快速找到最长递增子序列(其中每个下一个元素大于前一个元素的子序列)。

数据结构Data Structures

  • Cartesian Tree – Cartesian tree is a randomized balanced binary search tree.
  • Cartesian Tree with implicit keys – Cartesian tree with implicit keys is a powerful modification of cartesian tree, which can be used to solve many interesting problems. This implementation solves the problem of finding range minimum and also can perform reverse of an array segment.
  • Fenwick tree – Fenwick tree is a simple and easy-to-write data structure which can be used to find the value of some reversible function on the interval and also change the value of some element. This implementation can find the sum on the interval and update any arbitrary element.
  • Fenwick tree 2D – Extension of Fenwick tree on 2D case. This code can find the sum on the rectangle and update any arbitrary element.
  • Implicit segment tree – Implicit segment tree is a modification of segment tree which creates nodes only when they are needed. It can be used on big intervals like [1..109]. This code performs addition on the interval and getting the value of some element.
  • Queue with minimum – Modification of queue, which allows finding the minimum element in it.
  • Segment Tree (Add-Min-Max) – Segment tree is a powerful data structure which can perform many operations on the intervals in O(logN) time. This implementation performs addition and min/max interval.
  • Segment Tree (Assign-Sum) – Segment tree implementation that performs assignment and gets the sum on the interval.
  • Segment Tree (minimum on a segment and update) – Segment tree. Solves RMQ problem (maximum on a segment and value update).
  • Sparse table – Solves static RMQ problem (range minimum/maximum query without element changes).

几何学Geometry

  • Closest pair of points (Code 2) – Divide-and-conquer approach to find the closest pair of points.
  • Convex Hull (Code 2) – Graham-Andrew and Graham scan methods to find convex hull (the least convex polygon containing all given points).

图论Graphs

  • Bellman-Ford algorithm – Bellman-Ford algorithm finding shortest distances from a single vertex in graph.
  • Bipartite matching – Kuhn algorithm for maximum matching in bipartite graph.
  • Bridges search – Algorithm for finding all bridges in the graph (edges, after removal of which graph divides into several components).
  • Centroid decomposition – Centroid decomposition of a tree.
  • Cutpoints search – Algorithm for finding all cutpoints in the graph (vertices, after removal of which graph divides into several components).
  • Dijkstra algorithm (set version) – Finding minimum distances from the single source with Dijkstra algorithm. No negative edges are allowed. Best for sparse graphs. Two versions using set and heap.
  • Dinic maxflow – Dinic algorithm with scaling for finding the maximum flow.
  • Eulerian path/cycle – Algorithm for finding the Eulerian path/cycle, i.e. path/cycle that visits every edge of the graph exactly once.
  • Floyd-Warshall algorithm – Floyd-Warshall algorithm finding shortest distance between all pairs of vertices in graph.
  • Ford-Fulkerson maxflow – Ford-Fulkerson algorithm for finding the maximum flow.
  • Heavy-light decomposition – Heavy-light decomposition with segment trees in paths. Used for finding maximum on the path between two vertices.
  • Hungarian matching – Hungarian algorithm for solving the assignment problem.
  • LCA. Binary ascent. – Finding LCA (Least common ancestor) of two vertices in the tree. Uses dp calculated on powers of 2.
  • LCA. Heavy-light decomposition. – Finding LCA (Least common ancestor) of two vertices in the tree. Uses heavy-light decomposition.
  • MinCost MaxFlow Dijkstra (Heap Dijkstra) – Solution to MinCost MaxFlow (or simply MinCost Flow) using Dijkstra algorithm with potentials as shortest path search method.
  • MinCost MaxFlow Ford-Bellman – Solution to MinCost MaxFlow (or simply MinCost Flow) using Ford-Bellman algorithm as shortest path search method.
  • Minimum spanning tree. Kruskal algorithm – Kruskal algorithm for finding the minimum spanning tree (tree connecting the given graph with minumim sum of edges).
  • Minimum spanning tree. Prim algorithm – Prim algorithm for finding the minimum spanning tree (tree connecting the given graph with minumim sum of edges).

数论Number Theory

  • BigInt – Structure implementing long arithmetic in C++. Analogous to BigInteger in Java.
  • Catalan numbers – Finding Nth Catalan number modulo some mod (mod is not necessary prime). Uses Eratosthenes sieve for fast factorization.
  • Diophantine equation – Solving Diophantine equations in form of a * x + b * y = c. Uses extended Euclid algorithm (which finds such x, y that a * x + b * y = gcd(a, b)).
  • Fast Fourier transformation – Fast Fourier transformation used to multiply long numbers. Fast non-recursive version.
  • Gauss – Gauss method of solving systems of linear algebraic equation.
  • Matrix – Matrix multiplication and fast binary power.
  • Number by permutation – Finding number of permutation in lexicographical order.
  • Permutation by number – Finding permutation by its length and number in lexicographical order.

其它Other

  • Expression result calculation – Calculation of the value of the algebraic expression (like 2 * (5 + 7) - 25 / 5). Uses recursive descend. See code for the list of supported operations.
  • Merge sort – Merge sort for sorting the array of integers.
  • Quick sort – Quick sort with random pivoting for sorting the array of integers.
  • Radix sort – Radix sort for sorting the array of integers.

字符串Strings

  • Aho-Corasick – Aho-Corasick algorithm. This code finds all words in the text that contain any of the initially given words.
  • Hashing – Hashing in strings based problems. This code compares substrings using two hashes (one uses 2^64 as a modulo, another 10^9 + 7).
  • Manacher's algorithm – Manacher's algorithm for finding all subpalindromes in the string.
  • Palindrome tree – Useful structure to deal with palindromes in strings. This code counts number of palindrome substrings of the string.
  • Prefix function – Calculating the prefix function of the given string.
  • Suffix Array – Building suffix array in O(NlogN). Also LCP array is calculated. This code counts number of different substrings in the string.
  • Trie – Builds trie (tree with characters on the edges) from the set of strings. This code counts number of different substrings in the string.
  • Suffix Tree. Ukkonen's algorithm – Ukkonen's algorithm for building the suffix tree. Uses sibling lists in the nodes. This code counts number of different substrings in the string.
  • Z function – Calculating the Z-function of the given string.

算法编程Algos Programming的更多相关文章

  1. .Net中的反应式编程(Reactive Programming)

    系列主题:基于消息的软件架构模型演变 一.反应式编程(Reactive Programming) 1.什么是反应式编程:反应式编程(Reactive programming)简称Rx,他是一个使用LI ...

  2. C算法编程题系列

    我的编程开始(C) C算法编程题(一)扑克牌发牌 C算法编程题(二)正螺旋 C算法编程题(三)画表格 C算法编程题(四)上三角 C算法编程题(五)“E”的变换 C算法编程题(六)串的处理 C算法编程题 ...

  3. C算法编程题(七)购物

    前言 上一篇<C算法编程题(六)串的处理> 有些朋友看过我写的这个算法编程题系列,都说你写的不是什么算法,也不是什么C++,大家也给我提出用一些C++特性去实现问题更方便些,在这里谢谢大家 ...

  4. C算法编程题(六)串的处理

    前言 上一篇<C算法编程题(五)“E”的变换> 连续写了几篇有关图形输出的编程题,今天说下有关字符串的处理. 程序描述 在实际的开发工作中,对字符串的处理是最常见的编程任务.本题目即是要求 ...

  5. C算法编程题(五)“E”的变换

    前言 上一篇<C算法编程题(四)上三角> 插几句话,说说最近自己的状态,人家都说程序员经常失眠什么的,但是这几个月来,我从没有失眠过,当然是过了分手那段时期.每天的工作很忙,一个任务接一个 ...

  6. C算法编程题(四)上三角

    前言 上一篇<C算法编程题(三)画表格> 上几篇说的都是根据要求输出一些字符.图案等,今天就再说一个“上三角”,有点类似于第二篇说的正螺旋,输出的字符少了,但是逻辑稍微复杂了点. 程序描述 ...

  7. C算法编程题(三)画表格

    前言 上一篇<C算法编程题(二)正螺旋> 写东西前还是喜欢吐槽点东西,要不然写的真还没意思,一直的想法是在博客园把自己上学和工作时候整理的东西写出来和大家分享,就像前面写的<T-Sq ...

  8. C算法编程题(二)正螺旋

    前言 上一篇<C算法编程题(一)扑克牌发牌> 写东西前总是喜欢吐槽一些东西,还是多啰嗦几句吧,早上看了一篇博文<谈谈外企涨工资那些事>,里面楼主讲到外企公司包含的五类人,其实不 ...

  9. C算法编程题(一)扑克牌发牌

    前言 上周写<我的编程开始(C)>这篇文章的时候,说过有时间的话会写些算法编程的题目,可能是这两天周末过的太舒适了,忘记写了.下班了,还没回去,闲来无事就写下吧. 因为写C++的编程题和其 ...

随机推荐

  1. 【JDK8】Java8 LocalDate操作时间和日期的API

    时间项目中的涉及到的时间处理非常多,犹豫SimpleDateFormat的不安全性以及Calendar等类在计算时比较复杂, 往往我们都会使用工具类来封装较多的日期处理函数, 但是JDK8中新增了操作 ...

  2. dedecms后台一些时间等验证方法(plus/diy.php)

    <?php if(trim(@$_POST['name'])==''){ $err=2; } if(trim(@$_POST['tel'])==''){ $err=1; }else{ @$_PO ...

  3. 逆向工程第003篇:跨越CM4验证机制的鸿沟(上)

    一.前言 <冠军足球经理>系列作为一款拟真度极高的足球经营类游戏,赢得过无数赞誉,而CM4可以说是这个传奇的起点.但是在游戏安装过程中,当用户输入完序列号之后,程序并不会对用户的输入进行真 ...

  4. UVA10382喷水装置

    题意:       给你一个矩形的空地,然后有一些圆形的喷水装置,每个装置的圆心都在矩形宽的中间位置,然偶给你每个矩形的圆心位置和半径,问你最少多少个喷水装置可以把矩形的所有编辑都覆盖上. 思路:   ...

  5. Sqlmap的使用详解

    目录 Sqlmap Sqlmap的简单用法 探测指定URL是否存在SQL注入漏洞 查看数据库的所有用户 查看数据库所有用户名的密码 查看数据库当前用户 判断当前用户是否有管理权限 列出数据库管理员角色 ...

  6. 一个或多个筛选器或者Listeners启动失败 的问题探索以及解决方案

    2020年10月9日更新 经过本人对SSM框架理解的加深和对IDEA工具使用的熟悉,现提出一种新的解决办法,以前的解决办法可能存在问题 1. 问题描述: 使用IDEA作为开发工具,使用Maven作为项 ...

  7. PowerDesigner16安装和使用

    安装 安装参考链接:PowerDesigner安装教程 因为这个博主已经操作的很详细了,这边就不做过多的赘述. 使用 新建模型 选择物理模型 调出面板Palette 建表 最终的效果(一般不在数据库层 ...

  8. 有哪些适用于律师事务所的CRM系统?

    中国的经济发展和政治稳定给律师行业带来了巨大的空间.而互联网的发展也让律师事务所遍地开花.如何在大大小小的律所中脱颖而出,是每个律所都迫切需要解决的问题.为了让您的律师事务所在激烈的竞争中脱颖而出,今 ...

  9. docker 的常见命令行解析

    1.查看本地镜像 sudo docker images 2.查看本地容器 sudo docker ps 3.根据Dockerfile制作镜像命令 sudo docker build -t Myimag ...

  10. C#·JSON的处理和解析

    阅文时长 | 0.34分钟 字数统计 | 309.6字符 主要内容 | 1.引言&背景 2.声明与参考资料 『C#·JSON的处理和解析』 编写人 | SCscHero 编写时间 | 2021 ...