Powerset implementation. How???

Im a writing a program and one of the things it has to do is to construct a powerset from an interger array.
Powerset is a set of all subsets
for example int [] data = {1,2,3,4};
so the powerset should be a two dim array : {{1},{2},{3},{4}, {1,2},{1,3},{1,4},{2,3},{2,4},{3,4},{1,2,3}, {1,2,4},{1,3,4}, {2,3,4}, {1,2,3,4}}
This one is without the empty set - {}; so the number of elements in the powerset is 2^n - 1
I need a method in this form:
/** Takes an integer array and returns the powerset in two dim array */
public int [][] powerset(int [] data){
//some magic code here
So can anyone help me with this. I've been trying to do it myself for 2 days and now i know im completely stuck. Couldnt find any clues on the internet either
Your help would be very appriciated!

Well, having to use arrays leads to a lot of ugly low-level Java code which just gets in the way of the algorithm. But suppose you could work with sets instead. Here's the basic algorithm:public Set powerset(int n) {
  if (n <= 0) return new Set(empty set); // return a set containing a single, empty, set here
  Set p1 = powerset(n-1);
  Set p2 = powerset(n-1);
  // for each Set x in p2, replace it by x union {n}
  return p1 union p2;
}Try this by hand:
powerset(0) = {{}}, a set whose only element is the empty set.
powerset(1) = {{}} union {{1}} = {{} {1}}
powerset(2) = {{} {1}} union {{2} {1 2}} = {{} {1} {2} {1 2}}
and so on.

Similar Messages

  • Cash flow statement implementation - how did you do it? GL or other modules

    I would like to see the various ways you have successfully implemented a cash flow statement in the past.
    1) So far, the only one I did involved ABAP reporting using logic to group gl accounts and filtering transactions etc.
    2) Also, I've vaguely read that standard SAP's GL Lcash flow statement involves configuring a FSV which involves proper gl account structure to differentiate non-cash and cash related gl accounts.
    3) I've heard some projects used document types or document text fields or new fields to differentiate line items (cash or non-cash)
    Let's hear how you've done it with details if possible. Thanks.

    Hi
    Yes it involves GL Accounts Cash flow with configuring a FSV in SAP according to business requirement direct or indirect method.
    Rgds
    vani

  • Missing classe to implement How to Web Printing with MS Excel

    Hi there,
    we're trying to implement the How to paper "Web Printing with MS Excel". This paper comes with transport files to import the needed packages and classes.
    Now when I try to import that thing, the transport hangs. Checking the protocol shows that for each class there is the information: "Object ... was not included in this step."  Analysis shows that the Z-classes seem to inherit from the standard classes
    CL_RSR_WWW_GRID
    CL_RSR_WWW_HELP_WINDOW
    CL_RSR_WWW_ITEM_CONDITION
    CL_RSR_WWW_ITEM_EXCEPTION
    CL_RSR_WWW_ITEM_GRID
    CL_RSR_WWW_ITEM_TEMPLATE
    CL_RSR_WWW_ITEM_TEXT_ELEMENTS
    CL_RSR_WWW_TABLE
    These classes are in my Sneakpreview 04 but NOT in our BW System 3.5. Here the system infos:
    SAP_ABA     640     0015     SAPKA64015     Anwendungsübergreifende Komponente     Appl. Interface SP
    SAP_BASIS     640     0015     SAPKB64015     SAP Basiskomponente     Basis Support Pack.
    PI_BASIS     2005_1_640     0005     SAPKIPYJ65     Basis Plug-In (PI_BASIS) 2005_1_640     Kompon. Supp. Pack.
    SAP_BW     350     0015     SAPKW35015     Business Information Warehouse     Kompon. Supp. Pack.
    As the missing classes seem to be the problem, do I really have to get them out of my MiniSAP?
    Help appreciated
    Thanks
    Gerald
    ps. the transport file can easily be imported into the SneakPreview MiniSAP 6.40
    Message was edited by: Gerald Ressmann

    Hi,
    Here is the How to Web Printing with Excel, download from the Link
    This will expire in 7 days from the posting Date.<a href="http://download.yousendit.com/143673776AFD7E8F">How to Web Printing with Excel</a>
    Cheers.
    Ranga

  • Implementation - how to proceed

    Hi
    does any one have any information or implementated A1FS. I would like to kow what is the basic difference between Normal R/3 and A1FS. When I open up A1FS defalut config settings I could notice some sample configurations readiily available which are not there in R/3. Can any body guide me how to proceed as we have a project in A1FS implementation and I have no clarity regarding the basic difference and how should I proceed.
    Regards

    yes
    Gather the information of 0007  DWSR and other important infotypes form PA and OM

  • How to implement Product Licensing

    Hi all,
    In our company we are developing a web application(using java/JSP Servlets and any app server) for some warehouse. and i want to implement how to do licensing in my application. For example i want to give some one evaluation of my web application (Like we do in typical client server application of VB or D2K etc.)
    Evaluation licensing - expires after a specified number of days, should not work by changing system date of server etc.
    OR
    Named user licensing (Only defined no of users can be created fo using my application)
    OR
    Concurrent user licensing (no of concurrent user should not exceeds then specified)
    vikram

    Hi,
    We are developing the J2ME appications for our clients and those application talk to servlets on the backend and also there are jsp screens for database manipulation which is finally accessed by the mobile application. What we want is that we should have the control on as to how many servers can host the backend like we the client buys a license for one server then they should not be able to copy the jsps and servlets to another machine and use it. If they need another server to be added to the system they have to come to us , buy another license and the we wil setup another server for them. Also, for the J2ME application we need a feature which allows the user to try the application for a few days or a defined number of tries and then they have to buy it to use it ?
    I need the ideas and the ways in which I can do this kind of licensing and restrictions for both the j2me application and the backend server.
    thanks for the help offered.

  • How  to find the definintion for a particular implementation

    hi
    ihave the implementation name so i put this in se19
    and after enter it asks for definition which has to be created in se18
    if we have some predefined definitons  already for that implementation
    how to find the particular definiton that is to be used

    Put that implementation name in the enhancement name option of SE18 and press display. I hope by implementation you dont mean the Z Include.
    If it is Z include then look for where use list of that and pick the Enhancement name from there.
    Regards,
    Amit

  • How to implement State of charge kalman filter algorithm in C code

    hi,
    I am going to implement kamlan filter algorithm in C code. Is anyone here did this before. Please share your ideas and tell me how i can implement this. Give me some ideas. It would be highly apreciate. thanks in advance
    here i attached the kalman filter algorithm file.
    regards,
    usman
    Attachments:
    1.docx ‏74 KB

    Hi,
    did you already have a look at some implementations of the Kalman filter ? For example, that one : 
    Kalman filter c code implementation. How to tune required variables?
    http://forums.udacity.com/questions/1021647/kalman-filter-c-code-implementation-how-to-tune-required...
    or that one :
    http://alumni.media.mit.edu/~wad/mas864/psrc/kalman.c.txt
    Hope it helps!
    Aurelie

  • How do I utilize multiple instances of firefox utilizing different credentials, and retain full functionality.

    Recently my company made some "in the name of security" changes. One of these was to give local IT two windows accounts, one for e-mail and day to day activities, and the other for when administrative privileged is required.
    I have been using Firefox for years with out problems. I have made the tweaks for auto authentication to the domain as well as few others and everything has been working fine. Problem I am having is that now with my second credentials I have to have multiple browsers open so that the internal sites that require my privileged account authenticate properly. i have successfully gotten both Firefox (29.0.1) and Firefox portable (29.0.1) to run with my other credentials. (Love that -no-remote switch) My problem is any time something requires a plug-in YouTube(flash) The Firefox session started with my secondary (privileged) credentials starts displaying unresponsive script errors. This is a huge headache as several of my companies internal websites require both my secondary credentials, but they require flash as well?

    The unresponsive script can be troubleshooted or prevented with this recommended add on mentioned in this knowledge base article [http://mzl.la/LOwPvg] However it is strange that when you access the youtube site the other windows that are authenticated seem to timeout? or do they just hang?
    One way to narrow this down is to check what script is running in the web console tool found in the web developer menu. The warning will normally tell you what script is running and should give a hint. Other questions have mentioned it was this script: [https://support.mozilla.org/en-US/questions/982169 questions/982169]
    You can also try the new Firefox player being developed to play instead: [http://mozilla.github.io/shumway/] It would replace the default Flash player Youtube uses.
    For further investigation if this still happens after trying shumway:
    # What are the credentials being authenticated with? Both are windows accounts, however when visiting websites each authenticated windows account are logged in at the same time, how?
    # Autoauthentication is implemented how?
    #Multiple browsers? Does each browser only have one of the two authenticated accounts logged in?
    Thank you for your posts!

  • How can we customize the no of rows in Search options set?

    Hi all,
    I am using EP6 SP14, and i need to display the news from a folder based on a filter criteria ( like regions, etc) i am using a KM search iview with a query to search the items of the folder and the corresponding search options set limits the no of rows to a min 5 but i need only 3 items to be displayed with the page links to the browse the rest of the news. Can anyone suggest me if there is any way of customizing the no of rows or else i am thinking of using a KM navigation iview and using the corresponding query but strangely the layout doesnt work.....Anything i need to do more to limit the no of items to be displayed?
    Help would be greatly appreciated ,
    Santosh Kumar
    Edited by: Santosh Kumar Adapa on Nov 11, 2008 8:16 AM

    Hi Santosh,
    how about developing your own search?
    These blogs gives you a nice introduction of how to implement
    [How to write a Search Application using the KM Indexmanagement API for TREX|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5586]:
    [Using the KM Indexmanagement APIs for searching with TREX|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9237e490-0201-0010-f3a1-9a322ccbd8b1]
    Best regards,
    Denis

  • How to create reports

    Hi,
    I am new to BW please send me any helpful links, documents that are useful in creating reports, understanding the cycle of report creation.
    Thanks,
    Swetha

    Hi,
    those are bw reporting training course.
    check
    bex query designer, web reporting to mobile bi etc ...
    http://help.sap.com/saphelp_bw33/helpdata/en/5b/30d43b0527a17be10000000a114084/content.htm
    http://help.sap.com/saphelp_bw33/helpdata/en/a2/06a83a4bd5a27ae10000000a11402f/frameset.htm
    also there is 'bw reporting made easy' book/cd
    http://www.amazon.com/gp/product/1893570665/102-9958356-5476147?v=glance&n=283155
    web reporting, javascript etc
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/13dc9190-0201-0010-71a4-a9f56cdfcc72
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b1089290-0201-0010-288c-98e4d26487ee
    docs 'how to' related in service.sap.com/bi (need oss id)
    -> service and implementation -> how to
    for variable exit, virtual char/kf, table interface, bw ep reporting etc etc
    some available in this sdn forum (no id required)
    https://www.sdn.sap.com/irj/sdn/docs?rid=/webcontent/uuid/e7100a2e-0a01-0010-4fb3-d0578f754105 [original link is broken]
    e.g
    How to Calculate with Attributes
    This document explains how to calculate with attributes.
    How to Use Variable Time References in Currency Conversion
    This document explains how to use variable time references in currency conversions.
    How to Enhance Web Printing
    This document explains how to modify the format of BW Web Applications to improve the layout when printing from the web.
    How to Enhance the Standard Web Query Template
    This document explains how to upload a new web template (ZQUERY_TEMPLATE.htm) to the BEx Web Application Designer.
    www.bwexpertonline.com, vb macro etc
    http://www.bwexpertonline.com/downloads.cfm?session=
    e.g
    http://www.bwexpertonline.com/downloads/Nissen.doc
    http://www.bwexpertonline.com/downloads/boeke04.doc
    http://www.bwexpertonline.com/downloads/fox04.doc
    and all Raja's weblogs on bw query etc e.g
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b7658119-0a01-0010-39a9-b600c816f370
    and consider reporting performance, check especially Prakash weblog for good query design
    /people/prakash.darji/blog/2006/01/27/query-creation-checklist
    /people/prakash.darji/blog/2006/01/26/query-optimization
    oss note
    557870 'FAQ BW Query Performance'
    and 567746 'Composite note BW 3.x performance Query and Web'.
    BW Performance Tuning Knowledge Center - SAP Developer Network (SDN)
    Business Intelligence Performance Tuning [original link is broken]
    performance docs on query
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3f66ba90-0201-0010-ac8d-b61d8fd9abe9
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cccad390-0201-0010-5093-fd9ec8157802
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ce7fb368-0601-0010-64ba-fadc985a1f94
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c8c4d794-0501-0010-a693-918a17e663cc
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/064fed90-0201-0010-13ae-b16fa4dab695
    hope this helps.
    Regards
    Pavan Prakhya

  • Implement 2 conditions at a time

    hi all!
    I have two conditions.
    1. value of a kf <0 should be displayed
    2. only latest date should be populated.
    I could achieve them individually. but when i include both of them in conditions, only of them is being implemented.
    how do i acheive this?
    as ref:
    date is a characterstic. I used repl path and got Top1 value.
    for kf i used less than operator with value 0...
    Its damn urgent! Please help!
    Sri Harsha

    Hi,
    Instead of using a condition on Char you can restrict the key figure values as said in the previous post. And for Key figure values u can use the condition.
    Khaja

  • How To make un killable java application even by task manager ?

    Hi,
    Anybody help me how to we make un killable java application(applet).
    Thanks in Advance
    Mayan Alagar
    [email protected]

    Mayan_Alagar wrote:
    Anybody help me how to we make un killable java application(applet). Why do you think you need that?
    Tell us what problem you are trying to solve
    instead of asking how to implement how you think it should be solved.

  • CTS+ - How to hide "export using Filesystem" from PI tool?

    Hi experts,
    I have already implemented "How To  Configure Enhanced CTS PI 7.1", now I wonder If it is possible to hide export using Filesystem since I would like to force people using "Export using CTS" from PI tools.
    I have alredy surfing on internet without luck : (
    Could you pleas help with this?
    Thanks in advance.

    Hello Emili
    The Exchange Profile parameters below control whether the "Transport Using File System" option is visible in the transport wizard. If you set the parameters to "false" (without the " and all in lower case) then this transport option will no longer be visible.
    1) com.sap.aii.ibrep.core.transport.enableFileExport
    2) com.sap.aii.ibdir.core.transport.enableFileExport
    If these parameters do not already exist in the Exchange Profile, you can create them and set the value to false.
    Regards
    Mark

  • WM implemention- for Existing HUM , Fin.Goods Delivery - Textiles Industy.

    Dear WM Consultants,
    Have to implement WM  for Finished Goods warehouse for Textile Industry.
    The client is alreay working  on with Handling Unit Management for Delivery Doc creation Process.
    Handling Units being used to pack different types of finished goods into one pack and create Delivery for customers.
    would like to know whether  is it possible to go ahead with WM implementation, without impacting the existing Handling Unit Set  up and docs?.  If implemented , how and what could be the strategy to handle this? to safe gaurd the previous HU docs
    What are the major impacts over the  existing HU management system ? if WM is implemented.What are the major points to be considered in the initial study.? from the point of Textile  Industy Finished Products.
    Rgds..
    Ganapathi

    Hi Ravi,
    This is the standard functionality where the TO is created for picking based on storage type search - followed by storage bin search based on the startegy mentioned in config eg FIFO,LIFO etc. If you want the system to suggest pallets with complete boxes not partial first, then i think you will have to use userexit MWMTO007
    Regards,
    Vijay

  • In Cloud environment, do we still need to do an implementation?

    Hi,
    When we talk about cloud environment for Oracle Fusion Application, I am bit confused. Do we still need to do implementation on Oracle cloud or we can only subscribe to the services oracle provides?
    If we can not perform an implementation, how the data which resides in current Oracle EBS will be visible in Fusion?
    Also, is there any upgrade path available to upgrade from Oracle EBS to Fusion?

    see below link upgrade oracle EBS to fusion
    http://www.wipro.com/Documents/Wipro_Oracle%20R12_White_Paper_2111.pdf

Maybe you are looking for

  • Youtube not running in firefox, but works with internet explorer

    when i open you tube in Firefox, it does not run the videos. however the same runs good with internet explorer. a few weeks back the videos were running quite good with Firefox also.

  • I can't figure out how to add Audio Unit FX in Final Cut Pro X

    The title says it all. Any advice would be kindly appreciated. /K

  • IBook G4 slowdown with find and sort

    My wife's iBook frequently decides to slow down to a mere crawl, and it sounds like the hard drive (I think) is working steadily during these spells. Looking at the processes w/ top, find seems to be sucking up heaps of CPU time. I tried killing the

  • Multiple (3 or more) monitors for PXI 8110 controller​?

    I'm just fishing for help from the NI community out there to help a customer: has anyone had success using the PXI 8110 with multiple (3 or more) monitors?  I believe it can inherently support 2 monitors.  We've tried ADlink and Peritek cPCI cards wi

  • Item Cost at Delivery

    The DLN1 table stores the item cost at delivery.  Where is this value from?  When i drill into the item on the delivery and review the production order that this product came from the cost booked at production is different than the cost booked at del