If P = NP, why does P = NP = NP-Complete? [closed] - complexity-theory

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
If P = NP, why does P = NP also then equal NP-Complete?
I.e. Why would it then be the case that P = NP = NP-Complete?
Assuming P != NP , there were problems in NP not in NP - Complete.
When P = NP, all NP problems are actually now P.
Shouldn't there still be P = NP problems not in NP - Complete?

for future reference, no code = does not belong in stackoverflow...
as for your answer, http://en.wikipedia.org/wiki/NP-complete provides a full explanation. In 'layman' terms, all NP problems can be converted to an NP-C problem with a polynomial converter. that means that if P=NP, all of NP can be converted to NP-C which by definition can be converted to another NP-C etc. so P=NP=NP-C.

Related

Is there any better algorithm to calculate the partition number p(n) than Euler's Pentagonal number theorem [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Suppose I want to find partition number of n, aka p(n). Here Euler's Pentagonal number theorem, a dynamic programming based solution is present, which has time and complexities O(n^2), O(n^2\log(n)) respectively.
Is there any improvement over this algorithm to reduce complexity or is there any proof showing that this algorithm is the best possible for this problem/ reducing complexity bellow this is NP-hard. Also what about the space-time trade off. Can we reduce time/space complexity by increasing space/time complexity respectively (keeping in mind that each complexity should not be more that O(n^3).
The following recurrence can be directly translated to code:
where
,
import numpy as np
def num_partitions(n):
# recursive function with an auxiliary cache to avoid recomputing
# the same value more than once
def get(n, k, aux):
# terminate the recursion
if n < k:
return 0
if k == 1 or k == n:
return 1
# check if the value is already in the cache - if not, compute
# it recursively
if aux[n][k] == -1:
aux[n][k] = get(n-k, k, aux) + get(n-1, k-1, aux)
return aux[n][k]
return np.sum([get(n, k, np.ones((n+1,n+1)) * -1) for k in range(1, n+1)], dtype=np.int)
import sys
print(num_partitions(int(sys.argv[1])))

Modification for Dijkstra Algorithm [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to know, when the start vertex s is given, the shortest path is computed only if a vertex is no more than three edges away from the start vertex.
I thought of doing this by counting the number of parents, and if number_of_parents<=3 then it is a valid path.
Please can someone clarify this for me using the algorithm?
Below is the standard Dijkstra Algorithm.
Dijkstra(G,W,s)
Initialize_Single_Source(G,s)
S= {}
Q = V[G]
while Q != {} do
u = extract_min(Q)
S = S U {u}
for each vertex v element of Adj[u] do
relax(u,v,w)
Instead of a vertex we use array L to determine levels, i.e., how far a node is from the source
Dijkstra(G,W, s)
Initialize_Single_Source(G,s)
S= {}
Q = V[G]
L = {an array to determine levels of each node,
initially all nodes have level "infinite" except for s who has level 0}
while Q != {} do
u = extract_min(Q)
u_level = L[u]
if(u_level > 3){
ignore u and don't add it to S;
continue;
}
S = S U {u}
for each vertex v element of Adj[u] do
relax(u,v,w)
in relax function you put L[v] = min(L[v], u_level + 1);

Modulo equation, retrieve K from d [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Here's an equation:
d is the multiple inverse of 3 modulo K.
Assuming I have d, can I find K?
Also, K is not necessarily prime.
Thanks!
You know that
d*3 = 1 (mod K)
this means
d*3 = 1 + n*K
independently of K this however means
d*3 = 1 (mod n)
i.e. that d is the inverse of 3 modulo n too, thus the answer is in general not unique (actually you can use any divisor of nK as answer).

Expectation of the Sum of K Numbers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I am working on a histogram problem, and then I ran into the following math problem:
Given N numbers, where the value of each number is different, denoted as v1, v2, ..., vn, and the probability of selecting each number is p1, p2, ..., pn, respectively.
Now if I select K numbers based on the given probabilities, where K <= N, what is the expectation of the sum of those K numbers? Note that the selection is without replacement, so that the K numbers cannot involve duplicate numbers. I understand that if the selection is with replacement, the expectation of the sum of the K numbers equals K * E(V), where E(V) = v1*p1 + v2*p2 + ... + vn*p2.
Furthermore, what about the expectation of the variance of those K numbers?
This question is better formulated at here.

Go Fibonacci sequence generator [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
This is my fibonacci generator:
package main
import "fmt"
func main() {
for i, j := 0, 1; j < 100; i, j = i+j,i {
fmt.Println(i)
}
}
It's working, but I don't know how can I improve it, I'd like more expert approaches about it, Thanks...
I assume you are talking about improving the time complexity (and not the code complexity).
Your solution computes the Fibonacci numbers in O(n) time. Interestingly, there exists an O(log n) solution as well.
The algorithm is simple enough: Find the nth power of matrix A using a Divide and Conquer approach and report (0,0)th element, where
A = |1 1 |
|1 0 |
The recursion being
A^n = A^(n/2) * A^(n/2)
Time complexity:
T(n) = T(n/2) + O(1) = O(logn)
If you think about it with a piece of paper, you'd find that the proof is simple and is based upon the principle of induction.
If you still need help, refer to this link
NOTE: Of course, the O(logn) time is true only if you want to find the nth Fibonacci number. If, however, you intend to print ALL of the n fib numbers, theoretically, you can not have a better time complexity than you already have.

Resources