zoukankan      html  css  js  c++  java
  • 每个程序员都应该知道的14个数字(关于算法运行时间的)

    14 numbers every developer should know列举了14个数字,可以作为大家设计算法时的一个参考。下表列出了秒数量级下各种算法复杂度能接受的输入个数。

    maximum n

    complexity

    algorithms

    data structures

    1,000,000,000 and higher

    log n, sqrt n

    binary search, ternary search, fast exponentiation, euclid algorithm

     

    10,000,000

    n, n log log n, n log* n

    set intersection, Eratosthenes sieve, radix sort, KMP, topological sort, Euler tour, strongly connected components, 2sat

    disjoint sets, tries, hash_map, rolling hash deque

    1,000,000

    n log n

    sorting, divide and conquer, sweep line, Kruskal, Dijkstra

    segment trees, range trees, heaps, treaps, binary indexed trees, suffix arrays

    100,000

    n log2 n

    divide and conquer

    2d range trees

    50,000

    n1.585, n sqrt n

    Karatsuba, square root trick

    two level tree

    1000 - 10,000

    n2

    largest empty rectangle, Dijkstra, Prim (on dense graphs)

     

    300-500

    n3

    all pairs shortest paths, largest sum submatrix, naive matrix multiplication, matrix chain multiplication, gaussian elimination, network flow

     

    30-50

    n4, n5, n6

       

    25 - 40

    3n/2, 2n/2

    meet in the middle

    hash tables (for set intersection)

    15 - 24

    2n

    subset enumeration, brute force, dynamic programming with exponential states

     

    15 - 20

    n2 2n

    dynamic programming with exponential states

    bitsets, hash_map

    13-17

    3n

    dynamic programming with exponential states

    hash_map (to store the states)

    11

    n!

    brute force, backtracking, next_permutation

     

    8

    nn

    brute force, cartesian product

     
  • 相关阅读:
    使用SELECT语句检索数据
    redis的安装和使用【2】redis的java操作
    Python之数据结构改造
    InnoDB undo log物理结构的初始化
    Redis-RDB持久化设置
    MySql(四)Select条件查询
    Node.js TLS/SSL
    Node.js 定时器
    Node.js 系统
    Node.js 字符串解码器
  • 原文地址:https://www.cnblogs.com/fresky/p/3053155.html
Copyright © 2011-2022 走看看