-1

I want to know how 3 partition problem is NP complete ? We have to find triplets in set which sums to target. So isn't time complexity will be O(n^3) which is polynomial ?

solution: https://www.geeksforgeeks.org/find-a-triplet-that-sum-to-a-given-value

original question: https://en.wikipedia.org/wiki/3-partition_problem

Also, can someone explain the reduction from partition to 3 partition by example.

user
  • 25
  • 7

1 Answers1

0

The problem is not to find a triplet (which would be O(n^3)) but a way to split the set into triplets which all have the same sum; the brute-force approach would be to test all such partitions, which would not be polynomial.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
  • once we get all triplets, we can check if every number is included in partition which will be also in polynomial time ?. please correct me. – user Jun 06 '23 at 12:55
  • @user yes so verifying a solution is easy, which is a requirement for being NP-complete (it's the NP part). There are some proofs out there that show that it's also NP-hard, taken together they prove that problem is NP-complete (in NP and NP-hard). – harold Jun 06 '23 at 13:47