[algogeeks] Re: To find cartesian product of sets

2006-04-26 Thread Mukul Gandhi
Thanks for your comments.. I feel, this portion of code can be optimized as per your suggestion (I'll try to measure the improvement) > BufferedReader temp = new BufferedReader(new FileReader("out.txt")); > FileWriter ot = new FileWriter("temp.txt"); > String l = ""; > while ((l = temp.readL

[algogeeks] Re: To find cartesian product of sets

2006-04-26 Thread Vijendra Singh
I am not sure about how this file writing is being done, but I *think* you are writing it record by record, instead of that, u can try writing it block by block of say 1kb. that was your disk accesses are less and you write a bunch of data in a single shot. Not sure, how much will be the improvemen

[algogeeks] Re: To find cartesian product of sets

2006-04-26 Thread Mukul Gandhi
I experimented with your suggestion 1. Following is the modified function public static void cross(List sets) throws Exception { if (sets.size() == 2) { FileWriter op1 = new FileWriter("temp.txt"); FileWriter op2 = new FileWriter("out.txt"); for (int i = 0; i < ((Integer[])set

[algogeeks] Re: To find cartesian product of sets

2006-04-25 Thread Karthik Singaram L
You could do the following things:- 1. Try using a file to store all the intermediate results and the final output, rather than an array list or other class which stores the data in the main memory. This would mean no usage of the standard JAVA classes and low level programming but might just wo

[algogeeks] Re: To find cartesian product of sets

2006-04-25 Thread Mukul Gandhi
Just to add to my question, I would like the cartesian product program to scale upto 81 sets, and the cardinality of each set can be maximum 9. I calculated that the resulting cartesian product will have 1.9662705047555291361807590852691e+77 elements. I think it is difficult to store this cartesi