np-complete

Java: Traveling Salesman - Found polynomial algorithm

非 Y 不嫁゛ 提交于 2019-12-04 22:11:28
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, and if I do not get wrong there I will show you the rest of it. So what I am going to show you now, is

Minimal addition-chain exponentiation

血红的双手。 提交于 2019-12-04 21:38:49
问题 I know it has been proven NP-complete, and that's ok. I'm currently solving it with branch and bound where I set the initial upper limit at the number of multiplications it would take the normal binary square/multiply algorithm, and it does give the right answers, but I'm not satisfied with the running time (it can take several seconds for numbers around 200). This being an NP-complete problem, I'm not expecting anything spectacular; but there are often tricks to get the Actual Time under

Partitioning a list of integers to minimize difference of their sums

ぃ、小莉子 提交于 2019-12-04 14:50:57
Given a list of integers l , how can I partition it into 2 lists a and b such that d(a,b) = abs(sum(a) - sum(b)) is minimum. I know the problem is NP-complete, so I am looking for a pseudo-polynomial time algorithm i.e. O(c*n) where c = sum(l map abs) . I looked at Wikipedia but the algorithm there is to partition it into exact halves which is a special case of what I am looking for... EDIT: To clarify, I am looking for the exact partitions a and b and not just the resulting minimum difference d(a, b) To generalize, what is a pseudo-polynomial time algorithm to partition a list of n numbers

NP-Complete VS NP-Hard

 ̄綄美尐妖づ 提交于 2019-12-04 14:23:54
I am trying to understand the difference between NP-Complete and NP-Hard. Below is my understanding An NP-Hard problem is one that is not solvable in polynomial time but can be verified in polynomial time. An NP-Complete problem is one that is in NP and is also NP-Hard. Is the above definition correct? If so, What about problems not In NP but NP-Hard. Wouldn't they be harder than NP-Complete problem, say they can only be solved and verified in exponential time? A NP problem (not NP-Hard problem) is a decision problem which can be verified in polynomial time. Maybe they are solvable in

Is it correct to ask to solve an NP-complete problem on a job interview? [closed]

会有一股神秘感。 提交于 2019-12-03 15:13:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 years ago . Today there was a question on SO, where the author was given an NP-complete problem during an interview and he obviously hadn't been told that it was one. What is the purpose of asking such questions? What behavior does the interviewer expect when asking such things? Proof? Useful heuristics? And is it even

Minimal addition-chain exponentiation

瘦欲@ 提交于 2019-12-03 13:35:25
I know it has been proven NP-complete, and that's ok. I'm currently solving it with branch and bound where I set the initial upper limit at the number of multiplications it would take the normal binary square/multiply algorithm, and it does give the right answers, but I'm not satisfied with the running time (it can take several seconds for numbers around 200). This being an NP-complete problem, I'm not expecting anything spectacular; but there are often tricks to get the Actual Time under control somewhat. Are there faster ways to do this in practice? If so, what are they? This looks like

bin packing with overlapping objects

≯℡__Kan透↙ 提交于 2019-12-03 09:03:32
I have some bins with different capacities and some objects with specified size. The goal is to pack these objects in the bins. Until now it is similar to the bin-packing problem. But the twist is that each object has a partial overlap with another. So while object 1 and 2 has sizes s1 and s2, when I put them in the same bin the filled space is less than s1+s2. Supposing that I know this overlapping value for each pair of objects, is there any approximation algorithm like the ones for original bin-packing for this problem too? Masood_mj The answer is to use a kind of tree that captures the

Is it correct to ask to solve an NP-complete problem on a job interview? [closed]

倖福魔咒の 提交于 2019-12-03 04:55:54
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Today there was a question on SO, where the author was given an NP-complete problem during an interview and he obviously hadn't been told that it was one. What is the purpose of asking such questions? What behavior does the interviewer expect when asking such things? Proof? Useful heuristics? And is it even legitimate to ask one if it's not a well-known NP-complete problem everyone should know about? (there's a plenty of

What is a good algorithm for compacting records in a blocked file?

陌路散爱 提交于 2019-12-01 22:11:51
Suppose you have a large file made up of a bunch of fixed size blocks. Each of these blocks contains some number of variable sized records. Each record must fit completely within a single block and then such records by definition are never larger than a full block. Over time, records are added to and deleted from these blocks as records come and go from this "database". At some point, especially after perhaps many records are added to the database and several are removed - many of the blocks may end up only partially filled. What is a good algorithm to shuffle the records around in this

Reduction to Clique prob

家住魔仙堡 提交于 2019-12-01 11:44:20
Subgraph isomorphism We have the graphs G_1=(V_1,E_1), G_2=(V_2,E_2). Question : Is the graph G_1 isomorphic to a subgraph of G_2 ? (i.e. is there a subset of vertices of G_2, V ⊆ V_2 and subset of the edges of G_2, E ⊆ E_2 such that |V|=|V_1| and |E|=|E_1| and is there a one-to-one matching of the vertices of G_1 at the subset of vertices V of G_2, f:V_1 -> V such that {u,v} ∈ E_1 <=> { f(u),f(v) } ∈ E) Show that the problem Subgraph isomorphism belongs to NP. Show that the problem is NP-complete reducing the problem Clique to it. (Hint: consider that the graph G_1 is complete) I have tried