Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6840553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:51:29+00:00 2026-05-26T23:51:29+00:00

Given an integer array of size N by the user. Print all the possible

  • 0

Given an integer array of size N by the user.
Print all the possible sets such that sum of all possible numbers equate to a number in the array.

Example:

Array A[]= {1,2,3,4,5}

1+2=3..Output:1,2,3

1+3=4..Output:1,3,4

1+4=5..Output:1,4,5

Initial Design:

  1. Take a number and set it to SetSum
  2. Generate all sums excluding the selected number; checking that the formulated sum is same as the SetSum
  3. Print out the numbers that satisfies the conditions above.
  4. Iterate over the array and set the next number as SetSum

A much efficient Design/Implementation or different approach are welcome..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:51:30+00:00Added an answer on May 26, 2026 at 11:51 pm

    This problem requires you to find the subsets whose sum totals to a given number(here an element of the set). There are 2 approcahes to doing this:

    1. A brute force algorithm where you generate all the subsets manually and sum them all up which is of exponential order of growth (2^n combinations) or

    2. Use a dynamic programming approach to the problem and find the sum in polynomial time. This is a standard problem in algorithmics called the subset sum problem. If you are not familiar with the concept of dynamic programming, you can look up any algorithms text book. If you understand dynamic programming, then google for the subset sum problem. Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given an unsorted integer array, and without making any assumptions on the numbers in
Possible Duplicate: Getting the submatrix with maximum sum? Given a 2-dimensional array of positive
I have an assignment that is the following: For a given integer array, find
You are given a 32-bit unsigned integer array with length up to 2 32
Let A be an array of n positive integers, and k a given integer.
I have an integer array of size 50. So, as you know, initially the
We have an array A of integers of size N. Given another array B
I'm attempting to write an algorithm that takes an array of size n and
I have a byte array that can be of size 2,3 or 4. I
Given two integer numbers N and n (N >= n > 0), how do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.