[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

[algogeeks] Re: k connectivity

2006-04-26 Thread forest
finding all the paths is crazy)) in worst case you get about n! paths. But even having all the paths, it is not clear how you can find out if there are k of them sharing no vertex. It is sort of set covering problem that is not very easy by itself.

[algogeeks] Re: Chord Intersection

2006-04-26 Thread Dhyanesh
@pramod Arent all the 'n' chords part of the same circle ? If they are how can they be parallel without intersecting. If they are not of the same circle then its a different problem. @Karthik The complexity is not O(n). It is O(nlg(n)), since my first step is sorting the chords. Also you are

[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

[algogeeks] Ebook needed

2006-04-26 Thread programmer_2004
Hi Does anybody has the follwing ebook Data Structures and Program Design In C by Robert Kruse, Bruce P. Leung, Clovis L. Tondo. Published by Prentice Hall if yes please mail it to [EMAIL PROTECTED] Thanks and Regards Ashish Garg --~--~-~--~~~---~--~~ You

[algogeeks] Re: Finding the k largest/smallest elements in the array !

2006-04-26 Thread BiGYaN
Deepu, are you sure that this Algo will have an O(n) complexity. None of my friends and for that matter most of my teachers disagree with it having a linear time bound. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[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.readLine()) !=

[algogeeks] Re: Puzzle

2006-04-26 Thread W Karas
Venkatesh Dayalan wrote: Two unknowns x and y are to be found by two mathematicians M1 and M2. I give the Product(x * y) to M1 and Sum(x + y) to M2. Suppose that the product is 30. M1 doesn't know the value of S and M2 doesn't know the value of P. Now both the mathematicians enter

[algogeeks] Re: Help on modular arithmetic

2006-04-26 Thread Mikey
The answer to the first question is 2. When you take the modulus of a negative number, think of it as rounding down to a multiple of the divisor and taking the remainder. If you round down -22 to a multiple of 3, you get -24, and the difference between -22 and -24 is 2, your remainder. I'm not

[algogeeks] Re: Chord Intersection

2006-04-26 Thread W Karas
Dhyanesh wrote: 1 ) Radially sort the all the points of each chord (start and end both ). 2 ) Start with the first start point. Have c=1, tot=0, done[1..n]=0 3 ) Till all points are done: a ) If its a start point then tot = tot + c c = c + 1 set done for this

[algogeeks] Re: Chord Intersection

2006-04-26 Thread W Karas
Dhyanesh wrote: 1 ) Radially sort the all the points of each chord (start and end both ). 2 ) Start with the first start point. Have c=1, tot=0, done[1..n]=0 3 ) Till all points are done: a ) If its a start point then tot = tot + c c = c + 1 set done for this

[algogeeks] Re: Best way to sort linear dinamic list.

2006-04-26 Thread Gene
Lukas Šalkauskas wrote: oh thats!, maybe you can give me some examples? or maybe some links with good information about it. You asked for the best way, not for code! - #include stdio.h typedef struct node { struct node *next; } *NODE, NODE_REC;

[algogeeks] Counting Sort

2006-04-26 Thread pramod
Can we change counting sort to sort inplace only using O(k) space where the numbers range from 1...k? The problem precisely is to design a sorting algorithm to sort 'n' records whose keys range from 1...k in O(n) time using only an auxiliary array of size k. The algorithm should sort be stable

[algogeeks] Re: Best way to sort linear dinamic list.

2006-04-26 Thread Lukas Šalkauskas
Thanks!On 4/27/06, Gene [EMAIL PROTECTED] wrote: Lukas Šalkauskas wrote: oh thats!, maybe you can give me some examples? or maybe some links with good information about it.You asked for the best way, not for code!- #include stdio.htypedef struct node {

[algogeeks] Re: Chord Intersection

2006-04-26 Thread pramod
Dhyanesh: I am failing to see your point. Imagine a circle with origin as the center. You can very well imagine two chords parallel to x-axis. Say one is diameter and the other is some chord little above the diameter. These two don't intersect. How can two parallel chords in a circle intersect?

[algogeeks] Re: Best way to sort linear dinamic list.

2006-04-26 Thread Nat (Padmanabhan Natarajan)
Hi Gene,Thanks for the cool code!Cheers,NatOn 4/26/06, Gene [EMAIL PROTECTED] wrote: Lukas Šalkauskas wrote: oh thats!, maybe you can give me some examples? or maybe some links with good information about it. You asked for the best way, not for