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

  • SEARCH
  • Home
  • 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 7868075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:53:14+00:00 2026-06-03T00:53:14+00:00

Is there any efficient techniques to do the following summation ? Given a finite

  • 0

Is there any efficient techniques to do the following summation ?

Given a finite set A containing n integers A={X1,X2,…,Xn}, where Xi is an integer. Now there are n subsets of A, denoted by A1, A2, … , An. We want to calculate the summation for each subset. Are there some efficient techniques ?

(Note that n is typically larger than the average size of all the subsets of A.)

For example, if A={1,2,3,4,5,6,7,9}, A1={1,3,4,5} , A2={2,3,4} , A3= … . A naive way of computing the summation for A1 and A2 needs 5 Flops for additions:

Sum(A1)=1+3+4+5=13

Sum(A2)=2+3+4=9

…

Now, if computing 3+4 first, and then recording its result 7, we only need 3 Flops for addtions:

Sum(A1)=1+7+5=13

Sum(A2)=2+7=9

…

What about the generalized case ? Is there any efficient methods to speed up the calculation? Thanks!

  • 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-06-03T00:53:16+00:00Added an answer on June 3, 2026 at 12:53 am

    For some choices of subsets there are ways to speed up the computation, if you don’t mind doing some (potentially expensive) precomputation, but not for all. For instance, suppose your subsets are {1,2}, {2,3}, {3,4}, {4,5}, …, {n-1,n}, {n,1}; then the naive approach uses one arithmetic operation per subset, and you obviously can’t do better than that. On the other hand, if your subsets are {1}, {1,2}, {1,2,3}, {1,2,3,4}, …, {1,2,…,n} then you can get by with n-1 arithmetic ops, whereas the naive approach is much worse.

    Here’s one way to do the precomputation. It will not always find optimal results. For each pair of subsets, define the transition cost to be min(size of symmetric difference, size of Y – 1). (The symmetric difference of X and Y is the set of things that are in X or Y but not both.) So the transition cost is the number of arithmetic operations you need to do to compute the sum of Y’s elements, given the sum of X’s. Add the empty set to your list of subsets, and compute a minimum-cost directed spanning tree using Edmonds’ algorithm (http://en.wikipedia.org/wiki/Edmonds%27_algorithm) or one of the faster but more complicated variations on that theme. Now make sure that when your spanning tree has an edge X -> Y you compute X before Y. (This is a “topological sort” and can be done efficiently.)

    This will give distinctly suboptimal results when, e.g., you have {1,2}, {3,4}, {1,2,3,4}, {5,6}, {7,8}, {5,6,7,8}. After deciding your order of operations using the procedure above you could then do an optimization pass where you find cheaper ways to evaluate each set’s sum given the sums already computed, and this will probably give fairly decent results in practice.

    I suspect, but have made no attempt to prove, that finding an optimal procedure for a given set of subsets is NP-hard or worse. (It is certainly computable; the set of possible computations you might do is finite. But, on the face of it, it may be awfully expensive; potentially you might be keeping track of about 2^n partial sums, be adding any one of them to any other at each step, and have up to about n^2 steps, for a super-naive cost of (2^2n)^(n^2) = 2^(2n^3) operations to try every possibility.)

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

Sidebar

Related Questions

Is there any efficient algorithm to find the set of edges with the following
If we have an array of integers, then is there any efficient way other
Are there any efficient bitwise operations I can do to get the number of
Is there any speed- and cache-efficient implementations of trie in C/C++? I know what
Is there any way we could do efficient paging with petapoco and mvc3. At
Is there any time in which a reference type is more efficient than a
Are there any efficient XML parsers for Android to parse large XML files efficiently.
Is there any efficient linear algebra library for android? I need to compute matrices
Is there any efficient algorithms to check whether a binary string is periodic or
Is there any efficient way to convert an NSDate to RFC 2822 Date format

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.