Re: [algogeeks] four umbers sum to given value

2012-10-28 Thread atul anand
becoz you are sorting the aux[] , it seems to fine by replacing it with i j On 10/28/12, rahul sharma rahul23111...@gmail.com wrote: I wana ask that ccan i replcae while condiion with the condition as follow while(ij) code reference :http://www.geeksforgeeks.org/archives/23338 void

[algogeeks] C Macro

2012-10-28 Thread rahul sharma
Why the following code is not able to swap two macros???although it is easily swapping 2 variables #includestdio.h #define swap(a,b,c) c t;t=a,a=b,b=t int main int x=10,y=20; int *p,*q; swap(x,y,int); -- You received this message because you are subscribed to the Google Groups

[algogeeks] Re: #in macros

2012-10-28 Thread rahul sharma
And when char *opername=str(oper); then o/p is operwhy behaviour is diff. in 2 cases On Sun, Oct 28, 2012 at 2:53 PM, rahul sharma rahul23111...@gmail.comwrote: #includestdio.h #include str(x) #x #define Xstr(x) str(x) #define oper multiply int main() { char *opername=Xstr(oper);

Re: [algogeeks] Fork in c

2012-10-28 Thread Brijesh Kumar
output -text1text2 text2 explaination-system call fork creates a child process copying the whole code of parent but the execution of child process will start after the line where fork is called.thus the two process parent and child will print text2 twice -- You received this message

Re: [algogeeks] Fork in c

2012-10-28 Thread Brijesh Kumar
output - text1text2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit

Re: [algogeeks] Re: Range Checking Efficiently C++

2012-10-28 Thread Atul Singh
srry for my wrong typo.. it should be * unsinged( x - a ) (unsigned)b - a* works only for positive a and b a = b -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] Re: Range Checking Efficiently C++

2012-10-28 Thread Vikram Pradhan
how about ...if( (a-x)^(b-x) 0) On Sat, Oct 27, 2012 at 9:21 PM, Dave dave_and_da...@juno.com wrote: @Atul: Try x = 0, a = 1, b = 2, for which (x a x b) is false, but (x - a b - x) is true. Dave On Saturday, October 27, 2012 5:43:17 AM UTC-5, ATul SIngh wrote: Thnks but i figured

Re: [algogeeks] BIG O

2012-10-28 Thread Siddharth Malhotra
Can somebody explain how it is O(n log n). What is the significance of while loop in the above code? I understand that the for loop implies O(n),does the log n in the O(n log n) comes from the while loop? What if there where two while loops in the for loop separately? On Sat, Oct 27, 2012 at

Re: [algogeeks] Re: Range Checking Efficiently C++

2012-10-28 Thread Vikram Pradhan
we can use masking of most significant bit of the xor of (a-x) and ( b-x) to check if axb if [ ((a-x)^(b-x)) 0x8000 ] then it's in range else not in range On Sat, Oct 27, 2012 at 11:17 PM, Vikram Pradhan vpradha...@gmail.comwrote: how about ...if( (a-x)^(b-x) 0)

Re: [algogeeks] Re: Range Checking Efficiently C++

2012-10-28 Thread Ravi Ranjan
biku u also dere in this group... coool bro :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
it should swap On 10/28/12, rahul sharma rahul23111...@gmail.com wrote: Why the following code is not able to swap two macros???although it is easily swapping 2 variables #includestdio.h #define swap(a,b,c) c t;t=a,a=b,b=t int main int x=10,y=20; int *p,*q; swap(x,y,int);

[algogeeks] Re: LCA in BST

2012-10-28 Thread rahul sharma
how about this:- int leastCommanAncestor(struct node* root, int n1, int n2) { if(root==NULL) return -1; if(root-datan1 root-datan2) return leastCommanAncestor(root-left,n1,n2); else if(root-datan1 root-datan2) return leastCommanAncestor(root-right,n1,n2); return root-data; } correct if

Re: [algogeeks] BIG O

2012-10-28 Thread bharat b
while loop : logj base 2 .. == log1 + log2 + ... logn = log(n!) [since logab = loga + logb] == O(log(n^n)) = O(nlogn) On Sun, Oct 28, 2012 at 3:56 AM, Siddharth Malhotra codemalho...@gmail.comwrote: Can somebody explain how it is O(n log n). What is the significance of while loop in the above

[algogeeks] Re: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.

2012-10-28 Thread vikas
one optimization could be: Inorder(big).subString(inorder(small)) == true , then only execute this logic. On Friday, 26 October 2012 02:54:14 UTC+5:30, Don wrote: If T1 is a balanced tree with 50 million nodes, where the value of each node is 42, and T2 is a tree with 500 nodes with all

Re: [algogeeks] BIG O

2012-10-28 Thread Pralay Biswas
@ Siddharth : Well, here is how you may understand it: 1) There is an outer loop that runs n times. (k) 2) Then there is an inner loop where j is initially set to current k, but it halves itself in every iteration -- So for example, if k is 32, and j halves every time, then the inner

Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
didnt get you... first it was now working , now its working...!!! please write clearly about your doubts. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from