np-hard

P/NP/NP-Complete/NP-Hard

久未见 提交于 2019-12-21 00:28:07
1,计算复杂性   这是描述一种算法需要多少“时间”的度量。(也有空间复杂性,但因为它们能相互转换,所以通常我们就说时间复杂性。对于大小为 n 的输入,我们用含 n 的简化式子来表达。(所谓简化式子,就是忽略系数、常数,仅保留最“大”的那部分)   比如找出 n 个数中最大的一个,很简单,就是把第一个数和第二个比,其中大的那个再和第三个比,依次类推,总共要比 n-1 次,我们记作 O(n) (对于 n 可以是很大很大的情况下,-1可以忽略不计了)。   再比如从小到大排好的 n 个数,从中找出等于 x 的那个。一种方法是按着顺序从头到尾一个个找,最好情况是第一个就是 x,最坏情况是比较了 n 次直最后一个,因此最坏情况下的计算复杂度也是 O(n)。还有一种方法:先取中间那个数和 x 比较,如偏大则在前一半数中找,如偏小则在后一半数中找,每次都是取中间的那个数进行比较,则最坏情况是 lg(n)/lg2。忽略系数lg2,算法复杂度是O(lgn)。      2,计算复杂性的排序:   根据含 n 的表达式随 n 增大的增长速度,可以将它们排序:1 < lg(n) < n < nlg(n) < n^2 < ... < n^k (k是常数)< ... < 2^n。最后这个 2 的 n 次方就是级数增长了,读过棋盘上放麦粒故事的人都知道这个增长速度有多快。而之前的那些都是 n

P、NP、NP-Complete、NP-hard问题

眉间皱痕 提交于 2019-12-21 00:27:32
Table of Contents 1 遇到难题怎么办? 2 什么是P、NP、NP-Complete和NP-hard 3 P = NP ???? 4 参考 1 遇到难题怎么办? 遇到一个问题,通常我们思考的是如何解它。 于是就有了贪心、分治、动态规划等等算法;但也有一些问题,挠破了头也想不到高效的算法。 怎么办? 假如我们已经知道有那么几个问题,这个世界上所有的聪明人都没能找到高效的算法。 而且我们能把目前的问题通过等价转化的方式,变成这些已知问题的子问题。 这样就能证明我们不笨。 这个将一个问题,等价转换成另一个问题的子问题的方式,叫做 归约 (Reduction). 将问题A归约成问题B的子集 2 什么是P、NP、NP-Complete和NP-hard 这些概念都是用来描述一个问题的难度的。即一个问题能否在以上时间内求解,或者验证一个解是否符合一个问题。 在下面的讨论中,我们假设问题的输入规模是n,那么问题的解决时间,或者验证时间都应该是n的一个函数,记为$f(n)$. P, 即Polynomial time,多项式时间。f(n)=a0+a1*n1+a2*n2+a3*n3+…. 。 意思是说给定一个问题,能在多项式时间内 找到 符合该问题的解。此时,问题的时间复杂度是O(nj). 那不是多项式时间内能求解的问题,就是NP问题吗? 不是的 首先,要理解验证解的概念。给定一个问题

DCOS cluster resource allocation is np-hard

时光总嘲笑我的痴心妄想 提交于 2019-12-20 04:57:14
问题 Here in the DCOS documents it is stated that "Deciding where to run processes to best utilize cluster resources is hard, NP-hard in-fact." I don't deny that that sounds right, but is there a proof somewhere? 回答1: Best utilization of resources is variation of bin packaging problem: In the bin packing problem, objects of different volumes must be packed into a finite number of bins or containers each of volume V in a way that minimizes the number of bins used. In computational complexity theory

Maximizing the overall sum of K disjoint and contiguous subsets of size L among N positive numbers

本秂侑毒 提交于 2019-12-14 03:34:15
问题 I'm trying to find an algorithm to find K disjoint, contiguous subsets of size L of an array x of real numbers that maximize the sum of the elements. Spelling out the details, X is a set of N positive real numbers: X={x[1],x[2],...x[N]} where x[j]>=0 for all j=1,...,N. A contiguous subset of length L called S[i] is defined as L consecutive members of X starting at position n[i] and ending at position n[i]+L-1 : S[i] = {x[j] | j=n[i],n[i]+1,...,n[i]+L-1} = {x[n[i]],x[n[i]+1],...,x[n[i]+L-1]}.

P,NP,NPC,NP-hard

做~自己de王妃 提交于 2019-12-12 19:48:08
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> P问题:存在多项式复杂度算法的问题; NP问题:可以在多项式时间验证给定解是否正确的问题; NP-hard问题:任意一个NP问题都可以多项式时间规约到问题L,则称L为NP-hard问题; NPC问题:如果一个NP-hard问题L是一个NP问题,则称其为NP完全问题。 P和NP关系:P=NP or P≠NP?尚无定论,但可以确定的是NP包含P; NP和NP-hard关系:NP是NP-hard的真子集,因为存在有些NP-hard问题无法在多项式时间判断一个解是否可行; NPC:是NP和NP-hard的交集。 来源: oschina 链接: https://my.oschina.net/u/1757446/blog/755570

Tile Trial NP-hard complexity

核能气质少年 提交于 2019-12-12 02:48:54
问题 In the game Final Fantasy XIII-3, the player is presented with a couple puzzles. The first puzzle introduced is called Tile Trial , which presents the player with a grid of tiles, some of which have crystals on them. The goal is to retrieve all of the crystals and reach the exit, while stepping on each tile no more than once. The author of http://arxiv.org/pdf/1203.1633v1.pdf stated that this problem is NP-Hard because a specific case can be reduced to Hamiltonian-cycle. I find that this is a

How can some NP-Complete problems be also NP-Hard?

≯℡__Kan透↙ 提交于 2019-12-11 09:15:25
问题 I'm trying wrap my heard around P, NP, NP-Complete and NP-Hard in an intuitive way so that I don't have to remember their definitions. In the following image (the left hand scenario, P != NP), there's an overlapping area between NP-Complete and NP-Hard. Does it mean that some problems are both NP-Complete and NP-Hard? I find that contradictory, according to this particular answer: What are the differences between NP, NP-Complete and NP-Hard?. The table in the above link says an NP-Complete

Relationship between NP-hard and undecidable problems

折月煮酒 提交于 2019-12-09 08:33:39
问题 Am a bit confused about the relationship between undecidable problems and NP hard problems. Whether NP hard problems are a subset of undecidable problems, or are they just the same and equal, or is it that they are not comparable? For me, I have been arguing with my friends that undecidable problems are a superset to the NP hard problems. There would exist some problems that are not in NP hard but are undecidable. But i am finding this argument to be weak and am confused a bit. Are there NP

Java: Traveling Salesman - Found polynomial algorithm

ぃ、小莉子 提交于 2019-12-06 16:29:43
问题 Edit : An improvement to this algorithm been found. Your are welcome to see it. This question is the an improvement of my old question. Now I want to show you Java code sample, and explain my algorithm in more details. I think that I found a polynomial algorithm to get an exact solution to the Traveling Salesman Problem. My implementation is build from 5 steps: 1) Quick setup 2) Search for solution 3) Stop condition 1 4) Stop condition 2 5) Stop condition 3 I want to start from step 2 and 3,

Algorithm lesson final exam

纵饮孤独 提交于 2019-12-05 18:10:25
1、algorithm analysis O B/W/AV/AMOR,混入其他问题,设计+分析 2、传统算法(肯定要考) 1)divide and conquer master therem、 recursive tree、分析复杂度、递归树加起来得到最终结果 2)greedy algorithm example sort->select 拟阵 独立系统的贪心模板,直接得到近似比 3)dynamic programming sub-optimal structrue、编辑距离 3、graph algorithm 1)exproration bfs and dfs、最小生成树 2)最短路,single path all pair 负环、负边 3)max-flow 优化方式 4、turing machine Np/NPC NP-hard np-reduction 5、approximation greedy/sequential/local search/lp rouding 三种算法的设计、图算法、图灵机、近似算法 来源: https://www.cnblogs.com/elpsycongroo/p/11939165.html