np-complete

How to tell if greedy algorithm suffices for finding minimum coin change?

时间秒杀一切 提交于 2019-11-30 14:14:31
问题 The minimum coin change problem is an NP-complete problem but for certain sets of coins the greedy algorithm (choose largest denominations first) works. Given a set of integers denoting coin-values, what's the fastest algorithm to determine if the greedy algorithm suffices or not? One obvious way is to build up your dynamic programming solution till the largest denomination and see for each if it yields a better solution than the greedy way. But is there a faster "math-way" of detecting it?

np-completeness in the bounded degree spanning tree

荒凉一梦 提交于 2019-11-30 06:56:24
I understand why the Bounded Degree Spanning Tree is considered NP Complete with a degree or 2 (it is an instance of the Hamiltonian Path Problem), but I do not understand why this applies to degrees > 2. If someone could please explain why this is an NP Complete problem for degree > 2, It would be most helpful Bartolinio Well, I think that you can make a simple reduction from the instance of bounded by 2, to the instance of General k. Intuitivly, we will connect to each node of the original graph new k-2 nodes. Therefore every spanning tree will have to contain the k-2 edges from the original

Solving the NP-complete problem in XKCD

扶醉桌前 提交于 2019-11-29 19:43:25
The problem/comic in question: http://xkcd.com/287/ I'm not sure this is the best way to do it, but here's what I've come up with so far. I'm using CFML, but it should be readable by anyone. <cffunction name="testCombo" returntype="boolean"> <cfargument name="currentCombo" type="string" required="true" /> <cfargument name="currentTotal" type="numeric" required="true" /> <cfargument name="apps" type="array" required="true" /> <cfset var a = 0 /> <cfset var found = false /> <cfloop from="1" to="#arrayLen(arguments.apps)#" index="a"> <cfset arguments.currentCombo = listAppend(arguments

Algorithms to find the number of Hamiltonian paths in a graph

大憨熊 提交于 2019-11-29 10:45:23
I'm trying to solve a slightly modified version of the Hamiltonian Path problem. It is modified in that the start and end points are given to us and instead of determining whether a solution exists, we want to find the number of solutions (which could be 0). The graph is given to us as a 2D array, with the nodes being the elements of the array. Also, we can only move horizontally or vertically, not diagonally. Needless to say, we can't go from one city to two cities because to do that we would need to visit a city twice. I wrote a brute force solution that tries all 4 (3 or 2 for nodes on the

np-completeness in the bounded degree spanning tree

好久不见. 提交于 2019-11-29 07:54:58
问题 I understand why the Bounded Degree Spanning Tree is considered NP Complete with a degree or 2 (it is an instance of the Hamiltonian Path Problem), but I do not understand why this applies to degrees > 2. If someone could please explain why this is an NP Complete problem for degree > 2, It would be most helpful 回答1: Well, I think that you can make a simple reduction from the instance of bounded by 2, to the instance of General k. Intuitivly, we will connect to each node of the original graph

Are all scheduling problems NP-Hard?

隐身守侯 提交于 2019-11-28 20:32:21
I know there are some scheduling problems out there that are NP-hard/NP-complete ... however, none of them are stated in such a way to show this situation is also NP. If you have a set of tasks constrained to a startAfter , startBy , and duration all trying to use a single resource ... can you resolve a schedule or identify that it cannot be resolved without an exhaustive search? If the answer is "sorry pal, but this is NP-complete" what would be the best heuristic(s?) to use and are there ways to decrease the time it takes to a) resolve a schedule and b) to identify an unresolvable schedule.

Algorithms to find the number of Hamiltonian paths in a graph

痞子三分冷 提交于 2019-11-28 03:59:50
问题 I'm trying to solve a slightly modified version of the Hamiltonian Path problem. It is modified in that the start and end points are given to us and instead of determining whether a solution exists, we want to find the number of solutions (which could be 0). The graph is given to us as a 2D array, with the nodes being the elements of the array. Also, we can only move horizontally or vertically, not diagonally. Needless to say, we can't go from one city to two cities because to do that we

What's “P=NP?”, and why is it such a famous question? [closed]

送分小仙女□ 提交于 2019-11-28 02:30:46
The question of whether P=NP is perhaps the most famous in all of Computer Science. What does it mean? And why is it so interesting? Oh, and for extra credit, please post a proof of the statement's truth or falsehood. :) P stands for polynomial time. NP stands for non-deterministic polynomial time. Definitions: Polynomial time means that the complexity of the algorithm is O(n^k), where n is the size of your data (e. g. number of elements in a list to be sorted), and k is a constant. Complexity is time measured in the number of operations it would take, as a function of the number of data items

Are all scheduling problems NP-Hard?

你。 提交于 2019-11-27 20:44:35
问题 I know there are some scheduling problems out there that are NP-hard/NP-complete ... however, none of them are stated in such a way to show this situation is also NP. If you have a set of tasks constrained to a startAfter , startBy , and duration all trying to use a single resource ... can you resolve a schedule or identify that it cannot be resolved without an exhaustive search? If the answer is "sorry pal, but this is NP-complete" what would be the best heuristic(s?) to use and are there

What is an NP-complete in computer science?

谁都会走 提交于 2019-11-27 16:33:15
What is an NP-complete problem? Why is it such an important topic in computer science? Sam Hoice NP stands for Non-deterministic Polynomial time. This means that the problem can be solved in Polynomial time using a Non-deterministic Turing machine (like a regular Turing machine but also including a non-deterministic "choice" function). Basically, a solution has to be testable in poly time. If that's the case, and a known NP problem can be solved using the given problem with modified input (an NP problem can be reduced to the given problem) then the problem is NP complete. The main thing to