Creating a tree of all possible combinations of {a,b,c,d}

I am an MSc conversion student who is struggling with the initial stages of coding his Association Rule Mining dissertation project.
I have a TreeNode class, which is in the process of being written.
The class is designed to create a tree that stores all possible combinations of a Vector alphabet of strings {a,b,c,d}
Please could somebody explain what my TreeNode class is doing so far?
I have had a lot of help with this and I can't understand why there are so many vectors and what they all do.
A few pointers (no sarcastic comments please) would be much appreciated.
The code so far:
package treenode;
import java.io.*;
import java.util.*;
public class TreeNode
public static final String INFO_TEXT ="A program to store a vector of string items a,b,c,d in all their possible combinations into a TreeNode class";
private Vector alphabet;
private Vector data; // this IS TreeRootData
private Vector children;
public TreeNode(Vector inputAlphabet, Vector inputData)
// the alphabet and data have already been parsed in.
this.alphabet = inputAlphabet;
this.data = inputData;
System.out.println("Tree node constructed with data "+displayVectorOfStrings(this.data));
children = new Vector(); // we now construct the Vector of children
//createChildren();
public void createChildren()
if data.length =
// first check to see whether the current data length is the same
// as the length of the alphabet
// if it is then stop here (return;)
// we loop through the alphabet we have...
// for each candidate in the alphabet, attempt to create a new child TreeNode
// with a data Vector that is the same as the data in this TreeNode plus
// the candidate we are looking at in the alphabet. i.e. add available LHS
// NB: Do NOT add if the candidate is already in the data. {a,b,a} is wrong!
// NB: We will check to see whether data is already in the tree at a later stage
// NB: The new Child TreeNode MUST BE ADDED to the children VECTOR -
// or it will be lost
public static String displayVectorOfStrings(Vector vector) //Printing the Vector of Strings
String vectorText = "{";
for (int i=0; i<vector.size(); i++)
vectorText += (String)vector.elementAt(i)+",";
if (vector.size() > 0) vectorText = vectorText.substring(0, vectorText.length()-1);
// now we chop off the last element, replacing it with a closing bracket,
// provided that the Vector is not empty.
vectorText += "}";
return vectorText;
public static void main(String[] args) //main method WITH THE ARGUMENTS PASSED IN.
// This main class can be thought of as OUTSIDE the TreeNode class. Although
// it is in the file called TreeNode.java it is only here for convenience.
// This is the top level of the program where everything starts. It is here -
// that the alphabet is hardcoded in and that the Tree root is constructed.
displayHeading();
Vector alphabet = new Vector(); // constructing an initial alphabet,
alphabet.addElement("a"); // which will eventually come from the database
alphabet.addElement("b");
alphabet.addElement("c");
alphabet.addElement("d");
System.out.println("Alphabet set to be "+TreeNode.displayVectorOfStrings(alphabet));
// the root's initial data is now made into an empty Vector...
Vector initialData = new Vector();
// the root can now be constructed
TreeNode treeRoot = new TreeNode(alphabet, initialData); // the treeRoot constructor
public static void displayHeading()
System.out.println();
System.out.println(INFO_TEXT);

I don't remember from which site I took this material.
You read this to find all possible combination of a set {a,b,c,d}
Consider three elements A, B, and C. It turns out that for n distinct elements there are n! permutations possible. For these three elements all of the possible permutations are listed below:
ABC, ACB, BAC, BCA, CAB, CBA
Since there are 3 elements there are 3! = 6 permutations possible.
Suppose instead of A, B, and C you have a deck of 52 playing cards. There are 52! permutations possible (i.e., the number of different ways the cards could be shuffled). Since 52! = 8x10^67, you will need to play a lot of cards before you have seen every permutation of the deck! Since shuffling the deck is a random process (or it should be), each of these 52! permutations is equally likely to occur.
Developing a non-recursive algorithm to generate all permutations of n elements is a non-trivial task. However, developing a recursive algorithm to do this requires only modest effort and this is what we will do next.
1. Let E = {e1, e2, ..., en } denote the set of n elements whose permutations we are to generate.
2. Let Ei be the set obtained by removing element i from E.
3. Let perm(X) denoted the permutations of the elements in the set X.
4. Let ei.perm(X) denote the permutation list obtained by prefixing each permutation in perm(X) with element ei.
Consider the following example, which is provided to clarify the definitions given above:
If E = {a, b, c}, then E1 = {b, c} since the element in position 1 has been removed from E to create E1. Perm(E1) = (bc, cb) since these are the only two possible permutations of the two elements which appear in E1. Finally, e1.perm(E1) = (abc, acb) which should be apparent from the value of e1 and perm(E1) since the element a is simply used as a prefix to each permutation in perm(E1).
Given these definitions, we set the recursion base case when n = 1. Since only one permutation is possible for one element, perm(E) = (e) where e is the lone element in E. When n > 1, perm(E) is the list e1.perm(E1) followed by e2.perm(E2) followed by e3.perm(E3) � followed by en.perm(En). This recursive definition of perm(E) defines perm(E) in terms of n perm(X)s, each of which involves an X with n � 1 elements. Thus both the base component and the recursive component (of a recursive algorithm) have been established and we thus have a complete recursive technique to generate the permutations.
The following Java method is an implementation of this recursive definition of perm(E). This method will output all permutations whose prefix is list[0:k-1] and whose suffixes are the permutations of list[k:m]. By invoking the method with Perm(list, 0, n-1) all n! permutations of list[0: n-1] will be produced. [This is because this invocation will set k = 0 and m = n � 1, so the prefix of the generated permutations is null and their suffixes are the permutations of list[0: n-1]. When k = m, there is only one suffix which is list[m] and list[0: m] defines a permutation that is to be produced. When k < m, the else clause is executed.
In the algorithm, let E denote the elements in list[k: m] and let Ei be the set obtained by removing ei = list[i] from E. The first swapping sequence in the for-loop has the effect of setting list[k] = ei and list[k+1: m] = Ei. Therefore, next statement which is the call to perm computes ei.perm(Ei). The final swapping sequence restores list[k: m] to its state prior to the first swapping sequence (the state is was in before the recursive call occurred).
public static void perm(Object [] list, int k, int m)
{    //generate all permutations of list[k:m]
int i; Object temp;
if (k == m) //list has one permutation � so output it
{      for (i = 0; i <= m; i++)
System.out.print(list);
System.out.println;
else //list has more than one permutation � so generate them recursively
for (i = k; i <= m; i++)
{     temp = list[k]; //these next three lines are a simple swap function
list[k] = list[i];
list[i] = temp;
perm(list, k+1, m); //the recursive call
temp = list[k]; //reset the order in the list
list[k] = list[i];
list[i] = temp;
}//end for-loop
} //end method perm
See the program pasted below that prints all possible combination of a set {a,b,c,d}
public class Perm
public Perm()
public static void main(String[] args)
String s = "abcd";
char [] chars = s.toCharArray();
perm(chars, 0);
public static void perm(char [] list, final int k)
int i;
char temp;
if (k == list.length-1) //list has one permutation, so output it
for (i = 0; i <= list.length-1; i++)
System.out.print(list[i]);
System.out.println();
else { //list has more than one permutation, so generate them recursively
for (i = k; i <= list.length-1; i++)
temp = list[k]; //these next three lines are a simple swap function
list[k] = list[i];
list[i] = temp;
perm(list, k+1); //the recursive call
temp = list[k]; //reset the order in the list
list[k] = list[i];
list[i] = temp;
}//end for-loop

Similar Messages

  • All possible combinations of 23 columns in a table.

    Hi,
    We have a table as follows;
    CREATE TABLE ALL_PROD_COMB_TMP
    HDLM_ID NUMBER(10),
    MULTIPATH_ID NUMBER(10),
    TRUE_COPY_ID NUMBER(10),
    UVM_ID NUMBER(10),
    TUNING_ID NUMBER(10),
    CLUSTER_ID NUMBER(10),
    MIDDLEWARE_ID NUMBER(10),
    TAPE_ID NUMBER(10),
    THIRD_PARTY_ID NUMBER(10),
    NAS_ID NUMBER(10),
    HBA_ID NUMBER(10),
    BCM_ID NUMBER(10),
    VOLUME_MIGRATION_VERSION_ID NUMBER(10),
    TIERED_STO_MGR_VERSION_ID NUMBER(10),
    HDPS_ID NUMBER(10),
    SERVER_ID NUMBER(10),
    OS_ID NUMBER(10),
    DWDM_ID NUMBER(10),
    EXTENDER_ID NUMBER(10),
    SWITCH_ID NUMBER(10),
    INTERFACE_ID NUMBER(10),
    HUR_ID NUMBER(10),
    STORAGE_FAMILY_ID NUMBER(10)
    The data in the table is as follows;
    For formatting purpose the table data is shown in transposed form.
    Serial No. Column Name Data Value
    1     HDLM_ID                    377     586               
    2     MULTIPATH_ID               142     357               
    3     TRUE_COPY_ID               1     87     12          
    4     UVM_ID                    89     79               
    5     TUNING_ID               10     9     8          
    6     CLUSTER_ID               3     327     638          
    7     MIDDLEWARE_ID                         
    8     TAPE_ID                    3     47     54          
    9     THIRD_PARTY_ID               3                    
    10     NAS_ID                    12     91     1          
    11     HBA_ID                    300     400               
    12     BCM_ID                    14                    
    13     VOLUME_MIGRATION_VERSION_ID     13     12               
    14     TIERED_STO_MGR_VERSION_ID     1     2               
    15     HDPS_ID                    10     100               
    16     SERVER_ID               3     4               
    17     OS_ID                    2     7               
    18     DWDM_ID                    1                    
    19     EXTENDER_ID               520                    
    20     SWITCH_ID               4                    
    21     INTERFACE_ID               2     1     3     4     
    22     HUR_ID                    2     1     3     4     5
    23     STORAGE_FAMILY_ID          2
    Now we have another table named ALL_PROD_COMB having the same structure as that of ALL_PROD_COMB_TMP. In this ALL_PROD_COMB we need all the possible combinations of all the column values from ALL_PROD_COMB_TMP.
    We tried the following thing;
    insert into
         all_prod_comb (
         hdlm_id           
                                       ,multipath_id           
                                       ,true_copy_id           
                                       ,uvm_id                
                                       ,tuning_id           
                                       ,cluster_id           
                                       ,middleware_id
                                       ,tape_id
                                       ,third_party_id
                                       ,nas_id
                                       ,hba_id
                                       ,bcm_id
                                       ,volume_migration_version_id
                                       ,tiered_sto_mgr_version_id
                                       ,hdps_id
                                       ,server_id
                                       ,os_id                
                                       ,dwdm_id           
                                       ,extender_id           
                                       ,switch_id           
                                       ,interface_id           
                                       ,hur_id                
                                       ,storage_family_id
    select distinct
         a.hdlm_id           
                   ,b.multipath_id           
                   ,c.true_copy_id           
                   ,d.uvm_id                
                   ,e.tuning_id           
                   ,f.cluster_id           
                   ,g.middleware_id
                   ,h.tape_id
                   ,i.third_party_id
                   ,j.nas_id
                   ,k.hba_id
                   ,l.bcm_id
                   ,m.volume_migration_version_id
                   ,n.tiered_sto_mgr_version_id
                   ,o.hdps_id
                   ,p.server_id
                   ,q.os_id                
                   ,r.dwdm_id           
                   ,s.extender_id           
                   ,t.switch_id           
                   ,u.interface_id           
                   ,v.hur_id                
                   ,w.storage_family_id
         from (select hdlm_id from all_prod_comb_tmp) a
    ,(select multipath_id from all_prod_comb_tmp) b
    ,(select true_copy_id from all_prod_comb_tmp) c
                   ,(select uvm_id from all_prod_comb_tmp) d
                   ,(select tuning_id from all_prod_comb_tmp) e
                   ,(select cluster_id from all_prod_comb_tmp) f
                   ,(select middleware_id from all_prod_comb_tmp) g
                   ,(select tape_id from all_prod_comb_tmp) h
                   ,(select third_party_id from all_prod_comb_tmp) i
                   ,(select nas_id from all_prod_comb_tmp) j
                   ,(select hba_id from all_prod_comb_tmp) k
                   ,(select bcm_id from all_prod_comb_tmp) l
                   ,(select volume_migration_version_id from all_prod_comb_tmp) m
                   ,(select tiered_sto_mgr_version_id from all_prod_comb_tmp) n
                   ,(select hdps_id from all_prod_comb_tmp) o
                   ,(select server_id from all_prod_comb_tmp) p
                   ,(select os_id from all_prod_comb_tmp) q
                   ,(select dwdm_id from all_prod_comb_tmp) r
                   ,(select extender_id from all_prod_comb_tmp) s
                   ,(select switch_id from all_prod_comb_tmp) t
                   ,(select interface_id from all_prod_comb_tmp) u
                   ,(select hur_id from all_prod_comb_tmp) v
                   ,(select storage_family_id from all_prod_comb_tmp) w;
    But after looking at the explain plan we had to discard this. Simply not possible. Please help us with some other feasible solution.
    regards,
    Dipankar Kushari.

    Hi,
    That's what I have written while posting. Cartesian is no way possible. But is there any way so that I can find out all possible combination of the following values which is there in a table.
    1 HDLM_ID 377 586
    2 MULTIPATH_ID 142 357
    3 TRUE_COPY_ID 1 87 12
    4 UVM_ID 89 79
    5 TUNING_ID 10 9 8
    6 CLUSTER_ID 3 327 638
    7 MIDDLEWARE_ID
    8 TAPE_ID 3 47 54
    9 THIRD_PARTY_ID 3
    10 NAS_ID 12 91 1
    11 HBA_ID 300 400
    12 BCM_ID 14
    13 VOLUME_MIGRATION_VERSION_ID 13 12
    14 TIERED_STO_MGR_VERSION_ID 1 2
    15 HDPS_ID 10 100
    16 SERVER_ID 3 4
    17 OS_ID 2 7
    18 DWDM_ID 1
    19 EXTENDER_ID 520
    20 SWITCH_ID 4
    21 INTERFACE_ID 2 1 3 4
    22 HUR_ID 2 1 3 4 5
    23 STORAGE_FAMILY_ID 2
    regards,
    Dipankar.

  • Fill Array with all possible combinations of 0/1

    Hi,
    i'm looking for a fast way to fill an array, respectively an int[8], with all possible combinations of 0 and 1 (or -1 and 1, shouldn't make a difference).
    I kind of know how to do it using multiple loops but I assume there is a more elegant or at leaster "better" practice.
    Thanks,
    nikolaus
            static int cnt = 0;
         public static void main(String[] args) {
              int[] element = new int[]{1,1,1,1,1,1,1,1};
              Integer[] x = new Integer[2];
              x[0] = 1;
              x[1] = -1;
              for(int i7:x){
                   element[7] = i7;
                   for(int i6:x){
                        element[6] = i6;
                        for(int i5:x){
                             element[5] = i5;
                             for(int i4:x){
                                  element[4] = i4;
                                  for(int i3:x){
                                       element[3] = i3;
                                       for(int i2:x){
                                            element[2] = i2;
                                            for(int i1:x){
                                                 element[1] = i1;
                                                 for(int i0:x){
                                                      element[0] = i0;
                                                      cnt++;
              }Edited by: NikolausO on Oct 30, 2008 4:21 AM
    Edited by: NikolausO on Oct 30, 2008 4:22 AM

    pm_kirkham wrote:
    No I replied to message number 5. as the ' (In reply to #5 )' above my post indicates, which was in reply to (a reply) to Sabre150's post which wasn't using enhanced loops, nor has any obvious place where you could use that approach to fill the array.
    Though you could pass in an array of the values to fill the array with, and loop over those, instead of using 0 or 1, at which point Sabre's approach becomes the same as your OP, but without the manual unrolling:
    import java.util.Arrays;
    public class NaryCombinations {
    public interface CombinationHandler {
    void apply (int[] combination) ;
    public static void main(String[] args) {
    calculateCombinations(new int[]{-1, 0, 1}, 4, new CombinationHandler () {
    public void apply (int[] combination) {
    System.out.println(Arrays.toString(combination));
    public static void calculateCombinations (int[] values, int depth, CombinationHandler handler) {
    recursivelyCalculateCombinations(values, 0, depth, handler, new int[depth]);
    private static void recursivelyCalculateCombinations (int[] values, int index, int depth,
    CombinationHandler handler, int[] combination) {
    if (index == depth) {
    handler.apply(combination);
    } else {
    for (int value : values) {
    combination[index] = value;
    recursivelyCalculateCombinations(values, index + 1, depth, handler, combination);
    Which looks to use the same basic approach to the generalization I created shortly after posting the original.
    public class Scratch1
         * A 'callback' to be invoked with every combination
         * of the result.
        public interface Callback
             * Invoked for each combination.
             * <br>
             * Each call is passed an new instance of the array.
             * @param array the array containing a combination.
            void processArray(int[] array);
        public Scratch1(final int[] array, final Callback callback, final int... values)
            if (callback == null)
                throw new IllegalArgumentException("The 'callback' cannot be 'null'");
            if (array.length < 1)
                throw new IllegalArgumentException("The array length must be >= 1");
            if ((values == null) || (values.length < 1))
                throw new IllegalArgumentException("The 'values' must have be at least of length 2");
            callback_ = callback;
            values_ = values.clone();
            array_ = array;
        public Scratch1(final int order, final Callback callback, final int... values)
            this(new int[order], callback, values);
         * Generates every possible value and invokes the callback for each one.
        public void process()
            process(0);
         * Internal method with no logical external use.
        private void process(int n)
            if (n == array_.length)
                callback_.processArray(array_.clone());
            else
                for (int v : values_)
                    array_[n] = v;
                    process(n + 1);
        private final Callback callback_;
        private final int[] values_;
        private final int[] array_;
        public static void main(String[] args) throws Exception
            final Callback callback = new Callback()
                public void processArray(int[] array)
                    System.out.println(java.util.Arrays.toString(array));
            new Scratch1(6, callback, 2, 1, 0).process();

  • All possible combinations of a column as applied to a unique entry?

    i am having trouble getting a loop to do what i want, if you
    can help me find out what i am doing wrong i would appreciate it:
    i have a database with 3 tables in it
    table 1 has a list of documents - each one having a primary
    key
    table 2 has a list of document properties, i will call them
    property A, B, and C - each one having a primary key
    table 3 is a "relational" table that has a column for a
    document's PK and a property's PK that that document has
    Example of table 3:
    docPK / propPK
    1 (Document 1) / 1 (A)
    2 (Document 2) / 1 (B)
    3 (Document 3) / 2 (B)
    1 (Document 1) / 2 (B)
    1 (Document 1) / 3 (C)
    i need to create a loop in ColdFusion that spits out the
    number of possible combinations that exist for each document
    so the correct output should look like:
    Property A
    Document 1
    Property B
    Document 1
    Document 2
    Document 3
    Property C
    Document 3
    Property A, Property B
    Document 1
    Proberty A, Property B, Property C
    Document 1
    this output displays all possible combinations of properties
    under the conditions of existing documents
    here is the loop i have so far that does not seem to be
    working for me,
    <cfoutput query="rsProperties">
    <ul>
    <cfloop from="0" to="# of properties per document"
    index="i">
    <li>
    <cfoutput group="propPK">
    <cfif i EQ "# of properties per document">
    [#Trim(propertyName)#]
    </cfif>
    </cfoutput>
    </li>
    <ul>
    <cfoutput group="docPK">
    <li><a href="">#Document
    Name#</a></li>
    </cfoutput>
    </ul>
    </cfloop>
    </ul>
    </cfoutput>
    my loop returns possible combinations, but it is not
    returning ALL possible combinations, for example it may only return
    Property A as a single instead of also returning singles Property B
    and C
    my query simply consists of a SELECT * FROM [the database]
    WHERE [the three tables are set equal (as a join)] AND WHERE
    [documents exist]
    i know this is all rather confusing but if you can help me
    make sense of it i will be grateful
    thanks for your time

    Read the cfoutput section of the cfml reference manual. If
    you don't have one, the internet does.
    Look for the example that shows you how to use the group
    attribute.

  • Printing all possible combinations of a given word.

    Well I'm supposed to print all possible combinations of a given word(I'm writing this for the benefit of those who might not have guessed this from the subject). I've got some code but its horribly wrong. Could anyone point out any mistakes.
    public class Try
        public void display(String s)
            char ch[]=s.toCharArray();
            for(int i=0;i<ch.length;i++)
                String word="";
                word+=ch;
    char c[]=new char[s.length()];
    for(int j=0;j<ch.length;j++)
    if(ch[j]!=ch[i])
    c[j]=ch[j];
    for(int j=0;j<ch.length;j++)
    for(int k=0;k<ch.length;k++)
    if(c[j]!=c[k])
    word+=c[k];
    word+=c[j];
    System.out.println(word);

    Me and Lucifer have been workin on this program for ages.... we cant quite understand your pseudo code.. could you elaborate a bit more on how it works ??
    Meanwhile this is the dysfunctional program weve managed to come up with so far:
    public class SHAM
        public void display(String s)
            char c[]=s.toCharArray();
            for(int i=0;i<c.length;i++)
                String word="";
                char c1[]=new char[c.length-1];
                int a=0;
                for(int l=0;l<c.length;l++)
                    if(i!=l)
                        c1[a++]=c[l];
                for(int j=0;j<c.length-1;j++)
                    char c2[]=c1;
                    word=c[i]+word;
                    if(j+1!=c.length)
                        char t=c2[j];
                        c2[j]=c2[c2.length-1];
                        c2[c2.length-1]=t;
                    for(int k=0;k<c2.length;k++)
                        word+=c2[k];
                    System.out.println(word);               
    }And this is my coding of your pseudo code:
    public class WordCombo2
        public void combo(String s)
            getCombos(s.toCharArray(), s.length());
        private void getCombos(char[] c,int n)
            if (n==1)
                print(c);
                System.out.println();
            else
                for (int i=0;i<c.length;i++)
                    if (i==0 && i<n)
                        c=c[n-1];
    n--;
    getCombos(c,n);
    c[i]=c[n-1];
    private void print(char c[])
    for (int i=0;i<c.length;i++)
    System.out.print(c[i]+" ");
    I really dont understand how this is supposed to work so i dont know whats wrong :( Im sorry this program is just totally baffling me, and on top of that recursion kind of confuses me.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Generating all possible combinations question

    i'm trying to generate all possible combinations for several single column tables each with one string column.
    so - if table 1 has values (aa, ab, ac)
    table 2 has values (zz, zx)
    table 3 has values (qw, qe)
    the result set would contain all possible combinations:
    aa, ab, ac, zz, zx, qw, qe, aazz, aazx, aaqw, aaqe, aazzqw, aazzqe, aazxqw, aazxqe...etc.
    I've tried cross joins - but that does not get the smaller combinations.
    I've looked at some code examples but they seem to be focused on single letter or number combinations.
    I need to do this using tsql.
    code examples or links to such would be of much help.
    Thanks.

    Something like this might work:
    with t1 as (
    select val from table1
    union all
    select ''
    ), t2 as (
    select val from table2
    union all
    select ''
    , t3 as (
    Select val from table3
    union all
    select ''
    select t1.val + t2.val + t3.val
    from t1 cross join t2 cross join t3
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Help with oracle sql to get all possible combinations in a table.

    Hello guys I have a small predicatement that has me a bit stumped. I have a table like the following.(This is a sample of my real table. I use this to explain since the original table has sensitive data.)
    CREATE TABLE TEST01(
    TUID VARCHAR2(50),
    FUND VARCHAR2(50),
    ORG  VARCHAR2(50));
    Insert into TEST01 (TUID,FUND,ORG) values ('9102416AB','1XXXXX','6XXXXX');
    Insert into TEST01 (TUID,FUND,ORG) values ('9102416CC','100000','67130');
    Insert into TEST01 (TUID,FUND,ORG) values ('955542224','1500XX','67150');
    Insert into TEST01 (TUID,FUND,ORG) values ('915522211','1000XX','67XXX');
    Insert into TEST01 (TUID,FUND,ORG) values ('566653456','xxxxxx','xxxxx');
    "TUID"                        "FUND"                        "ORG"                        
    "9102416AB"                   "1XXXXX"                      "6XXXXX"                     
    "9102416CC"                   "100000"                      "67130"                      
    "955542224"                   "1500XX"                      "67150"                      
    "915522211"                   "1000XX"                      "67XXX"                      
    "566653456"                   "xxxxxx"                      "xxxxx"                       The "X"'s are wild card elements*( I inherit this and i cannot change the table format)* i would like to make a query like the following
    select tuid from test01 where fund= '100000' and org= '67130'however what i really like to do is retrieve any records that have have those segements in them including 'X's
    in other words the expected output here would be
    "TUID"                        "FUND"                        "ORG"                        
    "9102416AB"                   "1XXXXX"                      "6XXXXX"                     
    "9102416CC"                   "100000"                      "67130"                      
    "915522211"                   "1000XX"                      "67XXX"                      
    "566653456"                   "xxxxxx"                      "xxxxx"  i have started to write a massive sql statement that would have like 12 like statement in it since i would have to compare the org and fund every possible way.
    This is where im headed. but im wondering if there is a better way.
    select * from test02
    where fund = '100000' and org = '67130'
    or fund like '1%' and org like '6%'
    or fund like '1%' and org like '67%'
    or fund like '1%' and org like '671%'
    or fund like '1%' and org like '6713%'
    or fund like '1%' and org like '67130'
    or fund like '10%' and org like '6%'...etc
    /*seems like there should be a better way..*/can anyone give me a hand coming up with this sql statement...

    mlov83 wrote:
    if i run this
    select tuid,fund, org
    from   test01
    where '100000' like translate(fund, 'xX','%%') and '67130' like translate(org, 'xX','%%');this is what i get
    "TUID"                        "FUND"                        "ORG"                        
    "9102416AB"                   "1XXXXX"                      "6XXXXX"                     
    "9102416CC"                   "100000"                      "67130"                      
    "915522211"                   "1000XX"                      "67XXX"                      
    "566653456"                   "xxxxxx"                      "xxxxx"                      
    "9148859fff"                  "1XXXXXX"                     "X6XXX"                       the last item should be excluded. The second digit in "org" is a "7" Fund is wrong, too. You're looking for 6 characters ('100000'), but fund on that row is 7 characters ('1XXXXXX').
    and this is sitll getting picked up.That's why you should use the _ wild-card, instead of %
    select  tuid, fund, org
    from    test01
    where  '100000' like translate (fund, 'xX', '__')
    and    '67130'  like translate (org,  'xX', '__')
    ;It's hard to see, but, in both calls to TRANSLATE, the 3rd argument is a string of 2 '_'s.

  • How to create af:tree   programmatically

    Dear all,
    I want to create <af:tree> dynamically.
    all example i found on oracle web site is directly mapping with data controls.
    I don't want to use data control and i want to map manually.
    is there any example like that?
    With Regards,
    WP

    Thanks for ur reply,
    I try the example from that blog.
    Unfortunately, i get exception in my Jdev11.
    Oct 23, 2009 10:09:13 AM oracle.adfinternal.view.faces.config.rich.RegistrationConfigurator handleError
    SEVERE: Server Exception during PPR, #1
    javax.faces.model.NoRowAvailableException
         at javax.faces.model.ListDataModel.getRowData(ListDataModel.java:150)
         at oracle.adf.view.faces.model.SortableModel.getRowData(SortableModel.java:46)
         at oracle.adf.view.faces.model.ChildPropertyTreeModel.getRowData(ChildPropertyTreeModel.java:170)
         at org.apache.myfaces.trinidad.model.SortableModel.getRowData(SortableModel.java:67)
         at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel.getRowData(ChildPropertyTreeModel.java:207)
         at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel.isContainer(ChildPropertyTreeModel.java:219)
         at org.apache.myfaces.trinidad.component.UIXHierarchy.isContainer(UIXHierarchy.java:117)
         at oracle.adfinternal.view.faces.renderkit.rich.TreeRendererUtils._renderDisclosureIcon(TreeRendererUtils.java:2113)
         at oracle.adfinternal.view.faces.renderkit.rich.TreeRendererUtils.beginRenderIcons(TreeRendererUtils.java:250)
         at oracle.adfinternal.view.faces.renderkit.rich.TreeRenderer._renderDataCell(TreeRenderer.java:1472)
         at oracle.adfinternal.view.faces.renderkit.rich.TreeRenderer._renderDataBlockRows(TreeRenderer.java:1430)
         at oracle.adfinternal.view.faces.renderkit.rich.TreeRenderer._renderSingleDataBlock(TreeRenderer.java:1286)
         at oracle.adfinternal.view.faces.renderkit.rich.TreeRenderer._handleDataFetch(TreeRenderer.java:901)
         at oracle.adfinternal.view.faces.renderkit.rich.TreeRenderer.encodeAll(TreeRenderer.java:171)
         at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1187)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:751)
         at org.apache.myfaces.trinidad.component.UIXCollection.encodeEnd(UIXCollection.java:527)
         at org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(RenderUtils.java:70)
         at oracle.adfinternal.view.faces.util.rich.InvokeOnComponentUtils$RenderCallback.invokeContextCallback(InvokeOnComponentUtils.java:97)
         at org.apache.myfaces.trinidad.component.UIXCollection.invokeOnComponent(UIXCollection.java:1024)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents(UIXComponentBase.java:1312)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1406)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents(UIXComponentBase.java:1312)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1406)
         at oracle.adf.view.rich.component.rich.RichDocument.invokeOnComponent(RichDocument.java:159)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
         at oracle.adfinternal.view.faces.util.rich.InvokeOnComponentUtils.renderChild(InvokeOnComponentUtils.java:29)
         at oracle.adfinternal.view.faces.streaming.StreamingDataManager._pprComponent(StreamingDataManager.java:616)
         at oracle.adfinternal.view.faces.streaming.StreamingDataManager.execute(StreamingDataManager.java:465)
         at oracle.adfinternal.view.faces.renderkit.rich.DocumentRenderer._encodeStreamingResponse(DocumentRenderer.java:2608)
         at oracle.adfinternal.view.faces.renderkit.rich.DocumentRenderer.encodeAll(DocumentRenderer.java:969)
         at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1187)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:751)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.__encodeRecursive(UIXComponentBase.java:1494)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeAll(UIXComponentBase.java:771)
         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
         at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:271)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:202)
         at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:189)
         at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:685)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:261)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:193)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.share.http.ServletADFFilter.doFilter(ServletADFFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:54)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

  • Possible combination of coins

    Hello, I'm just new here. I have some algorithm problem with algorithm that couldn't put it to a code. The problem is "For a given denomination of money (5, 10, 20, 50, 100), get all possible combinations that will not exceed 2000 and at least one of them is present".
    I know this is easy for others but for me, it's quite difficult. I already searched but I can't find something that is similar with this problem.
    Here's what I tried,
    Given:
    denominations = { 5, 10, 20, 50, 100};
    total = 2000;
    A=5, B=10, C=20, D=50, E=100
    A' = counts of A // A' >= 1
    B' = counts of B // B' >= 1
    C' = counts of C // C' >= 1
    D' = counts of D // D' >= 1
    E' = counts of E // E' >= 1
    A A' + BB' + C*C' + D*D' + E*E' <= total
    The problem is I can't find a way for a possible counts of the denomination.
    Any help is much appreciated.
    Thanks.

    For a brute force approach, consider a simpler problem:
    Can you solve the problem if denominations = {5} and maxValue = 1820?
    For each solution of the problem the above case, does it generate a smaller problem to be solved for the next higher denomination in {5, 10, 20, 50, 100}?
    Can you see how to get a solution to the bigger problem from the smaller ones?
    If you've done data structures in your course, you may also want to make it more efficient by memotisation so you don't recompute the combinations of 20,50,100 given 10 = 2 * 5 etc.

  • All possible race outcomes

    Hey,
    This is my problem - I'm making a program that will print all possible outcomes of a race, given that ALL participants can be disqualified, and logically, that there can not be several same places.
    Say that we have 2 competitors. My idea was/is to put all the options into an array razvrstitve = (1st place, 2nd place, disqualification, disqualification), and then print all the possible permutations of it. Problem is that it also considers all disqualifications to be separate, so it, will for example print out that "1st driver : disqualified (taking in razvrstitve[2]), 2nd driver: disqualified (razvrstitve[3])" and "1st driver : disqualified (taking in razvrstitve[3]), 2nd driver: disqualified (razvrstitve[2])", which is practically the same and shouldn't be printed out.
    Output example(odstop means disqualification):
    1. Voznik: 2. mesto 2. Voznik: odstop
    1. Voznik: odstop 2. Voznik: odstop
    1. Voznik: 1. mesto 2. Voznik: odstop
    1. Voznik: odstop 2. Voznik: odstop
    1. Voznik: 2. mesto 2. Voznik: odstop
    1. Voznik: 1. mesto 2. Voznik: odstop
    1. Voznik: odstop 2. Voznik: 1. mesto
    1. Voznik: odstop 2. Voznik: 1. mesto
    1. Voznik: 2. mesto 2. Voznik: 1. mesto
    1. Voznik: odstop 2. Voznik: 2. mesto
    1. Voznik: odstop 2. Voznik: 2. mesto
    1. Voznik: 1. mesto 2. Voznik: 2. mesto
    I've tried with creating new arrays and not "letting in" those elements, which's exact order has already been printed, but It's not working like it should :/
    Anyway, here is my code (the one that prints out all permutations, including duplicates), so if anyone has any ideas or pointers of how I can do what I want it'd be greatly appreciated.
    Regards,
    Sumo
    public class Naloga4 {
         public static void main(String[] args) {
            int mest = 0;     
              int stTekmovalcev = 2;     // number of competitors a.k.a
              //how long permutations should be
            int N = 2*stTekmovalcev; // number of options, inluding disqualification of
            //possibly every participant          
            int[] razvrstitve = new int[N];     
            for (int i = 0; i < N; i++) { // creates an array with all options inside            
                 if (i < stTekmovalcev) {
                      razvrstitve[i] = 0;
                 } else {
                      razvrstitve[i] = mest+1;
                      mest++;
            razvrsti(razvrstitve, razvrstitve.length, stTekmovalcev);     
        private static void razvrsti(int[] razvrstitve, int n, int r) {     // prints out all possible permutations
            if (r == 0) {
                   for (int i = n; i < razvrstitve.length; i++) {
                        String mesto = "";
                        if (razvrstitve[i] != 0) {
                             mesto = String.valueOf((int) razvrstitve) + ". mesto";
                        } else {
                             mesto = "odstop";
    System.out.printf((i-n+1) + ". Voznik: " + mesto + " ");
    System.out.println();
    return;
    for (int i = 0; i < n; i++) {
    zamenjaj(razvrstitve, i, n-1);
    razvrsti(razvrstitve, n-1, r-1);
    zamenjaj(razvrstitve, i, n-1);
    public static void zamenjaj(int[] razvrstitve, int i, int j) {     // swaps positions in the array
         // so all permutations can be made
    int temp = razvrstitve[i];
    razvrstitve[i] = razvrstitve[j];
    razvrstitve[j] = temp;

    Here is the above code translated, if it helps:
    public class ResultsPermutations {
         public static void main(String[] args) {
            int setResult = 0;     
              int nrOfCompetitors = 2;     // number of competitors a.k.a
              //how long permutations should be     
            int N = 2*nrOfCompetitors;      // number of options, including disqualification of
            // possibly every participant     
            int[] possibleresults = new int[N];     
            for (int i = 0; i < N; i++) {           // creates an array with all possible results 
                 if (i < nrOfCompetitors) {
                      possibleresults[i] = 0;
                 } else {
                      possibleresults[i] = setResult+1;
                      setResult++;
            enumerate(possibleresults, possibleresults.length, nrOfCompetitors);     
        private static void enumerate(int[] possibleresults, int n, int r) {     // prints out all possible permutations
            if (r == 0) {
                   for (int i = n; i < possibleresults.length; i++) {
                        String place = "";
                        if (possibleresults[i] != 0) {
                             place = String.valueOf((int) possibleresults) + ". place";
                        } else {
                             place = "Disqualification";
    System.out.printf("Driver " + "#" + (i-n+1) + ": " + place + " ");
    System.out.println();
    return;
    for (int i = 0; i < n; i++) {
    swapArray(possibleresults, i, n-1);
    enumerate(possibleresults, n-1, r-1);
    swapArray(possibleresults, i, n-1);
    public static void swapArray(int[] possibleresults, int i, int j) {          // swaps positions in the array
         // so all permutations can be made
    int temp = possibleresults[i];
    possibleresults[i] = possibleresults[j];
    possibleresults[j] = temp;

  • Is it possible to create hierarchical tree report (not group tree) CR2008?

    Hi,
    Is it possible to create hierarchical tree kind report using CR 2008(no group tree in the report)?  The report somewhat look like below and a node can have multiple Child and so and so. Is there any magical way either as a chart or any object which supports the below structure.
                                                          Parent1
                                           Child1              Child2             Child3             Child4          Child5
                     Child1A     Child1B      Child1C
        Child1Aa  Child1Ab
    its hierarchical tree  structure and it should be in detail section of the report so that print in paper is possible.
    Please help first of all, can we able to create a report in above structure(each item needs to be surronuded with box and the each last child will contain a table valued data.
    (if I post this thread, it may look like plain text, please consider the above data as a hierarchical tree  structure with child having N number of children)
    Thanks

    Moved from .NET Development - Crystal Reports forum to Crystal Reports Design forum.
    Ludek

  • Is it possible to create a tree with drag-and-drop functionality using ajax

    I saw these samples;
    Scott Spendolini's AJAX Select List Demo
    http://htmldb.oracle.com/pls/otn/f?p=33867:1:10730556242433798443
    Building an Ajax Memory Tree by Scott Spendolini
    http://www.oracle.com/technology/pub/articles/spendolini-tree.html
    Carl Backstrom ApEx-AJAX & DHTML examples;
    http://htmldb.oracle.com/pls/otn/f?p=11933:5:8901671725714285254
    Do you think is it possible to create a tree with drag-and-drop functionality using ajax and apex like this sample; http://www.scbr.com/docs/products/dhtmlxTree/
    Thank you,
    Kind regards.
    Tonguç

    Hello,
    Sure you can build it, I just don't think anyone has, you could also use their solution as well in an APEX page it's just a matter of integration.
    Carl

  • Show all the possible combinations of n elements in an array???

    If I have an array of n elements, how to show all the possible combinations of n elements.
    What is the java library for doing the combinations??
    For example,
    public class CombinationTest
    {     public static void main(String[] args)     
         {     ArrayList letters = new ArrayList();
              leters.add("s1");
              leters.add("s2");
              leters.add("s3");
    Find all the combinations of 3 elements: C(3,2). Here's the result:
    1) s1, s2
    2) s1, s3
    3) s2, s3
    }

    There isn't a built-in API method for this. Still, combinations are pretty easy. Pseudocode (borrowing notation from ML and GJ, and assuming immutable sets): Set<Set<Object>> getCombinations(int itemsInCombo, Set<Object> itemsToCombine)
        // Handle base case and exceptional cases
        if (itemsInCombo = 0) return Set.emptySet();
        if (itemsInCombo < 0) throw new Exception("?!");
        // Recursive case
        Object o = itemsToCombine.first(); // use iterator - may throw exception
        // Get combos with first element
        Set<Set<Object>> rv = map (x => x.add(o)) getCombinations(itemsInCombo - 1, itemsToCombine.remove(o));
        // Add combos without first element
        rv.add(getCombinations(itemsInCombo, itemsToCombine.remove(o)));
        return rv;
    }

  • Easiest way to sum all possible (different) combinations in an array?

    Hey guys, 
    Say I have an array of sorted values (of attenuation), I want to generate an array of all possible sums of those values, sort it, then refer to it as a list of all possible attenuation values (lets say theyre bits on a discrete digital attenuator).  I will try to show you an example of what I mean with letters:
    Array of attens: [a, b, c, d]
    I want an array like this: [a+b,  a+c,  a+d,  a+b+c,  a+b+d,  a+c+d,  b+c,  b+d,  b+c+d]... I hope I'm not missing any combos here...
    I'm attaching my attempt at this idea but there's something missing I think, I am doing something wrong...
    Thanks for any ideas or help.
    Solved!
    Go to Solution.
    Attachments:
    Sum all possible combos.vi ‏18 KB

    Ben wrote:
    The challenge is getting all possible combos.
    Have you concidered looking at this as a variation on binary counting?
    The total number of combinations is 2^(NumberOfSettings) if you include "None".
    So generate a ramp from zero to the total number possible.
    Convert each number to a boolean array and then use the boolean to determine if its corresponding value gets add into the total.
    After processing all of the values from the ramp the final array should be in ascending order.
    I hope that outline helps,
    Ben
    Ben, that is actually quite brilliantly simple.  I like it.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is it possible to create a database of all my ipad apps that are currently on my Apple ID with out manually typing in the data?

    I would like to find a way to create a database of all the apps I have downloaded.  Would anyone know a way to take the information in an Apple account and place it into a database?

    Could see what Meraki will do.
    Meraki -- A free MDM
      http://www.meraki.com/products/systems-manager/
      https://discussions.apple.com/thread/4067210?tstart=0

Maybe you are looking for

  • HELP:  How do you tell iPhoto 08 not to import dupes?

    Hi, I was just looking at iPhoto 08 preferences and I can not see where I choose not to import duplicates... where or can you toggle this? I imported from an external hard drive and I just dragged the top level folder into iPhoto to begin the import.

  • What is wrong with my mac

    Hey I purchased a crucial 256 m4 ssd. it was not working stable at all on my mbp mid 09 15'' 2,53. lags, freeze, read and write speed around 37 mb/s. Crucial said i should try in an other mac and I did a 13'' mbp from mid 10. same specs as mine mbp.

  • How do I post a message on the qosmio forum?

    Hi, I see messages on the qosmio forum pages but no mention of "post a new topic" this is the only page I can see that allows me to post a topic. I wish to post a topic asking what cables are included in the qosmio f20-136 in UK as I seem to be missi

  • Firefox for Android crashes often for me, I believe its because my tablet has a low amount of RAM.

    I have a low-end tablet that (despite having 8GB of storage), only has 512MB of memory/RAM. I've already encountered a few games that won't run because of this limitation. Up until now, it was things I could live without. But I get frequent Firefox c

  • Thread Safeness of JDBC Drivers

    I am having lots of problems with accessing the database through Oracle's thin/thick JDBC drivers in a multithreaded applicaiton. Does anyone know anything about how thread safe are Oracle's JDBC drivers? I am using one connection in all the threads.