4)Given a set of integers, Display the non-empty subsets whose sum is zero. For example, given the set { −7, −3, −2, 5, 8}, the answer is the subset { −3, −2, 5} which sums to zero. This is the special case of knapsack problem and hence it is NP- Complete so i said we cannot find the solution in polynomial time.We consider all the subsets with k elements. Then check how many of these sets have a sum of 0. This is an exponential time algorithm

AnswerBot
1y

The problem is to find non-empty subsets of a given set of integers whose sum is zero.

  • The problem is a special case of the knapsack problem and is known to be NP-Complete.

  • A brute-force approach would ...read more

Help your peers!
Add answer anonymously...
Directi Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter