[algogeeks] Re: C/C++ Programming

2006-05-12 Thread adak
Jordan Greenberg posted: "Using a spell checker is probably a good idea as well." Having some meaninful content in your post, is an even better idea, Jordan. This is NOT a spelling bee forum! Adak . --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] Re: Generate all possible Interleavings of two arrays

2006-05-12 Thread Gene
Gene wrote: > > #include > > void interleave(char *a, int ia, char *b, int ib, char *r, int ir) > { > if (ir < 0) > printf("%s\n", r); > else { >if (ia >= 0) { > r[ir] = a[ia]; > interleave(a, ia - 1, b, ib, r, ir - 1); >} >if (ib >= 0) { > r[ir] = b[ib]; >

[algogeeks] Re: Find an iterative method to do the traversal of a binary search tree (inorder say)....

2006-05-12 Thread Feng
But to setup a threaded binary tree needs to traval the whole tree first.On 5/13/06, thomas <[EMAIL PROTECTED] > wrote: Feng wrote: When you visit a node N which has two children ( binary tree, for example ) L(N) and R(N), if the next step is visiting L(N), then save L(N) and make L(N) p

[algogeeks] Re: Find an iterative method to do the traversal of a binary search tree (inorder say)....

2006-05-12 Thread thomas
Feng wrote: When you visit a node N which has two children ( binary tree, for example ) L(N) and R(N), if the next step is visiting L(N), then save L(N) and make L(N) points to N's father which has been saved before. The pointers to fathers take place of stack or recursion. On 5/13/06,

[algogeeks] Are We Addressing Cyber Crime Backwards

2006-05-12 Thread ted9925
Maybe that is why it continues to grow despite all the hard work to stop it: http://fraudwar.blogspot.com/2006/05/are-we-addressing-cyber-crime-from.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm G

[algogeeks] Re: Find an iterative method to do the traversal of a binary search tree (inorder say)....

2006-05-12 Thread Feng
When you visit a node N which has two children ( binary tree, for example ) L(N) and R(N), if the next step is visiting L(N), then save L(N) and make L(N) points to N's father which has been saved before. The pointers to fathers take place of stack or recursion. On 5/13/06, Manu <[EMAIL PROTECTED]>

[algogeeks] Re: Generate all possible Interleavings of two arrays

2006-05-12 Thread Gene
Imran Mohammed Abdul Muqsith wrote: > Hi, > > Can anyone give the algo to generate all possible interleavings of two > arrays (better if its in C or Java) > > E.g. > A1[] = {a,b}; > B1[] = {c,d}; > > # Results = (2+2)!/(2! .2!) = 6 > > abcd > acbd > acdb > cabd > cadb > cdab #include void inter

[algogeeks] Generate all possible Interleavings of two arrays

2006-05-12 Thread Imran Mohammed Abdul Muqsith
Hi, Can anyone give the algo to generate all possible interleavings of two arrays (better if its in C or Java) E.g. A1[] = {a,b};B1[] = {c,d}; # Results = (2+2)!/(2! .2!) = 6 abcdacbdacdbcabdcadbcdab   -- Mohammed Abdul Muqsith ImranDepartment of Computer Science and Engineering,Indian Institute o

[algogeeks] Find an iterative method to do the traversal of a binary search tree (inorder say)....

2006-05-12 Thread Manu
Find an iterative method to do the traversal of a tree (inorder say) without using recursion and without using stack... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to thi

[algogeeks] Re: find pair in O(N)

2006-05-12 Thread Manu
well if the index of the elements are not imp then it's fine...but if they are then may be we will have to use some other way.. like find all the indexes from left (i) and right(j) till the sum is equal to the required sum and then find all possible pair of the indexes. thnx --~--~-~--~

[algogeeks] Re: Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-12 Thread aj
well the set (X + Y) will have O(n^2) elements, where X and Y have n elements. As an example X = {1, 2} Y = {3, 5} X + Y = {1 + 3, 1 + 5, 2 + 3, 2 + 5} = {4, 5, 6, 7} Now the problem is to find the median of X + Y in subquadratic time. thx aj --~--~-~--~~~---~--~--

[algogeeks] Re: find pair in O(N)

2006-05-12 Thread shishir
Why do you want both the pairs to be printed? I guess the problem's originality is only in finding unique pairs summing to a particular number, so there's no point in printing repeating pairs. Besides, even if you want to do that, daizi's code can be altered quite simply to print repeating pairs.

[algogeeks] Re: find pair in O(N)

2006-05-12 Thread Manu
i m referring to daizi's algo. n = size of num i = 0 j = n-1 while(i < j) { c = num[i] + num[j] if(c < given number) i++ else if(c > given number) j-- else show and j-- } --~--~-~--~~~---~--~~ You received this message because you are subscri

[algogeeks] Re: find pair in O(N)

2006-05-12 Thread Manu
well i guess the algo is fine if the elements are not repeating but when they repeat i think there is some problem as all possible pairs are not printed for eg. 1,1,2,3,4,5 then this algo prints <1,5> only once becoz then poitner j decrements and we never compare the next 1 with 5 -

[algogeeks] Re: Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-12 Thread W Karas
aj wrote: > How about finding the median of (X + Y) in subquadratic time. > X + Y = {z | z = xi + yj for some i and j}. > > I could only reduce the space complexity from O(n^2) to O(n) but time > complexity still > remains O(n^2). > > thx > Aj Can't you merge the two sorted array in O(n) into a

[algogeeks] Re: Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-12 Thread W Karas
W Karas wrote: > Vibhu wrote: > > How wud you handle the case where > > > > X= {1, 3, 5, 7, 9} > > Y= {2,4,6,8} > > > > What wud be timecomplexity ? > > Here is a more general solution, covering cases > like your example where X and Y have different > dimensions: > > Let Nx be dimension of X, Ny

[algogeeks] Re: C/C++ Programming

2006-05-12 Thread Mattia Merzi
On 5/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > [...] I Spend My Whole Summer Devoted > To Programming And Learning... please, please, please, you are 13, go outside, play football with your friends, try to go by bike, go to the seaside, swim, play, and enjoy your being 13, you have an

[algogeeks] Re: Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-12 Thread aj
How about finding the median of (X + Y) in subquadratic time. X + Y = {z | z = xi + yj for some i and j}. I could only reduce the space complexity from O(n^2) to O(n) but time complexity still remains O(n^2). thx Aj --~--~-~--~~~---~--~~ You received this messa