[algogeeks] Re: Adobe Interview - 20/08/2011
oops On Aug 28, 7:09 pm, Decipher ankurseth...@gmail.com wrote: @vikas - As i said earlier think in 3D . The correct answer is (sqrt(3) - 1)R/(sqrt(3) + 1) = r Using 3D coordinate geometry if (R,R,R) and (r,r,r) are the coordinates of center of large and small sphere . Then , make distance formula for centers of sphere in 3D = (R+r) *Now don't ask distance formula in 3D* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c doubt
it will be 00. Bit fields are allocated within an integer from least-significant to most-significant bit. In the following code struct mybitfields { unsigned short a : 4; unsigned short b : 5; unsigned short c : 7; } test; int main( void ); { test.a = 2; test.b = 31; test.c = 0; } the bits would be arranged as follows: 0001 0010 cccb On Mon, Aug 29, 2011 at 10:31 AM, kartik sachan kartik.sac...@gmail.comwrote: @PRATEEK if i make int bit1:2 then it will store 2 bytes for example if bit1=4;then out will be 0 or 1 my question is it storing number from least significant bit or most significant bit??? suppose for 4 0100 so out will be 00 or 01?? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech Computer Science And Engineering National Institute of Technology -Allahabad -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How to save a binary search tree space efficiently
@vikas : you can use recursive approach to draw tree here we go: 6 4 3 5 7 8 11 12 1 ) 6 is root since 4 6 , 4 is left child of 6 2) find value which is more than 6 , so it is 7 in this case... hence 7 is right child. 3 ) Hence we break this list in three part; 1. Root node (6)2. left sub tree (4,3,5) 3. right subtree (7,8,11,12) 6 / \ (4,3,5) (7,8,11,12) we repeat same 3 steps for left and right sub tree. So we need only one Preorder traversal. On Mon, Aug 29, 2011 at 1:22 AM, vikas vikas.rastogi2...@gmail.com wrote: @ Sagar, level order can be stored but you need to remember the nulls always On Aug 29, 12:06 am, sagar pareek sagarpar...@gmail.com wrote: level order traversal is best for this case :) On Sun, Aug 28, 2011 at 11:53 PM, prashant thorat prashantnit...@gmail.comwrote: only preorder will suffice.. considering fact that it's BST On Sun, Aug 28, 2011 at 11:26 PM, Rishabbh A Dua duarish...@gmail.com wrote: Please correct me if i am wrong but isnt the answer to this q is AVL trees On Sun, Aug 28, 2011 at 10:43 PM, Dhriti Khanna dhriti0...@gmail.com wrote: @ Navneet: See if the tree is: 6 4 7 3 5 8 Then the preorder traversal is : 6 4 3 5 7 8 And using this preorder traversal and inserting them in the tree one by one, we generate this exact tree. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Rishabbh A Dua -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explanation
#define g(a) #a replaces any occurrence of g(a) with string a. #define f(a,b) a##b replaces any occurrence of f(a,b) with concatenation of a and 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How to save a binary search tree space efficiently
store inorder traversal in the array and while reconstructing form a tree around mid element using recursion... -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How to save a binary search tree space efficiently
@ankit: I think it wont work in below case : 9 \ 18 \ 27 \ 36 Inorder traversal : 9-18-27-36 mid element is 18 or 27 On Mon, Aug 29, 2011 at 12:59 PM, ankit gupta ankit.itc...@gmail.comwrote: store inorder traversal in the array and while reconstructing form a tree around mid element using recursion... -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explanation
Plz explain the solution.. Acc to me it should be.. 12 12 On 8/29/11, PRATEEK VERMA prateek...@gmail.com wrote: #define g(a) #a replaces any occurrence of g(a) with string a. #define f(a,b) a##b replaces any occurrence of f(a,b) with concatenation of a and 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sent from my mobile device Sahil Garg Computer Engg. DCE -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] confusion
Please specify the difference between Array of pointer and Pointer to array???it's getting very messy -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Probability Q(Mean nd Variance)
Let X and Y be jointly distributed random variables such that the conditional distribution of Y, given X=x, is uniform on the interval (x-1,x+1). Suppose E(X)=1 and Var(X)=5/3. Q.1 The mean of the random variable Y is First question using common data: (A) 1/2(B) 1(C) 3/2 (D) 2 Q.2 The variance of the random variable Y is Second question using common data: (A) 1/2(B) 2/3 (C) 1 (D) 2 Plz anyone provide correct answer with explanation Vijay.. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explanation
Hi, See Question 11.17 of C FAQ . http://c-faq.com/ansi/stringize.html In the first case f(1,2) happens first and in the second case g(X) happens first and then f(1,2) Hence in the first case - h(f(1,2,)) = h(12) = 12 and second case = g(f(1,2)) = f(1,2) In other words Case1: - Expanding macro h: - a = f(1,2) - Expanding macro f: - a##b = 12 = 12 = g(12) - Expanding macro g: - #a is replaced by a string: #a = 12 O/P = 12 Case 2: - Expanding macro g: - #a = f(1,2) O/P = f(1,2) Macros are evil. Regards, Vrashabh Irde On Mon, Aug 29, 2011 at 1:06 PM, Sahil Garg garg.sahi...@gmail.com wrote: Plz explain the solution.. Acc to me it should be.. 12 12 On 8/29/11, PRATEEK VERMA prateek...@gmail.com wrote: #define g(a) #a replaces any occurrence of g(a) with string a. #define f(a,b) a##b replaces any occurrence of f(a,b) with concatenation of a and 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sent from my mobile device Sahil Garg Computer Engg. DCE -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] confusion
Array of pointers is= *a=A[10]; Pointers to array means= *A[10]; is this correct? On Mon, Aug 29, 2011 at 1:14 PM, Nitin coolguyinat...@gmail.com wrote: Please specify the difference between Array of pointer and Pointer to array???it's getting very messy -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explanation
Why in the first case f(1,2) is evaluated first ? Any plausible explanation for that ? Sanju :) On Mon, Aug 29, 2011 at 12:50 AM, Vrashabh Irde vrashab...@gmail.comwrote: Hi, See Question 11.17 of C FAQ . http://c-faq.com/ansi/stringize.html In the first case f(1,2) happens first and in the second case g(X) happens first and then f(1,2) Hence in the first case - h(f(1,2,)) = h(12) = 12 and second case = g(f(1,2)) = f(1,2) In other words Case1: - Expanding macro h: - a = f(1,2) - Expanding macro f: - a##b = 12 = 12 = g(12) - Expanding macro g: - #a is replaced by a string: #a = 12 O/P = 12 Case 2: - Expanding macro g: - #a = f(1,2) O/P = f(1,2) Macros are evil. Regards, Vrashabh Irde On Mon, Aug 29, 2011 at 1:06 PM, Sahil Garg garg.sahi...@gmail.com wrote: Plz explain the solution.. Acc to me it should be.. 12 12 On 8/29/11, PRATEEK VERMA prateek...@gmail.com wrote: #define g(a) #a replaces any occurrence of g(a) with string a. #define f(a,b) a##b replaces any occurrence of f(a,b) with concatenation of a and 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 unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sent from my mobile device Sahil Garg Computer Engg. DCE -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] tejas 2010 coding test
use seive or store only prime numbers in an array by squareroot method On Sun, Aug 28, 2011 at 9:15 AM, Prags onlypr...@gmail.com wrote: Q- Fibonacci series for prime no only ..there were lot of restrictions given we need to write an optimised code -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] confusion
Array of Pointers : By Array of Pointers we mean that there is an array that contains the pointers at different index which points to some value in the memory. Example:- int *arr[10] In this array arr[0],arr[1]arr[9] is a pointer that points to some value in a memory. Pointer to array : By Pointer to array we means that there is a pointer that is defined to point to some index in an array. Example:- There is some array arr and we define a pointer a; int *a = arr; then this points to value arr[0]; and if int *a = arr+9; then this points to value arr[9]; -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) -- sapraaks...@gmail.com akshatsapr...@gmail.com rit2009...@iiita.ac.in sapraaks...@facebook.com -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] confusion
int *p[10]=array of pointers meaning they can can point to 10 integer type locations int (*p)[10] =pointer of array which can point to an array of size 10 *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] SPOJ Problem DIVSUM
hi see the logic all the factors of a number are evenly distributed about it's square root for e.g 100 1 X 100 2 X 50 4 X 25 5 X 20 10 X 10 AFTER THIS THE PAIRS REPEATE THEMSELVES BUT IN OPPOSITE ORDER 20 X 5 25 X 4 50 X 2 100 X 1 SO IF YOU MAKE YOUR LOOP GO TO SQRT(N) AND IF YOU FIND A FACTOR OF THAT NUMBER ANOTHER FACTOR CAN BE FOUND BY DIVING THAT FACTOR WITH THE NUMBER FOR E.G. IF YOU FIND 4 THEN 25 IS FOUND BY 100/4 #includestdio.h #includemath.h main() { long long int n,i,t,d,k,l; // long int a,b; scanf(%lld,t); while(t) { d=0; scanf(%lld,n); k=sqrt(n); for(i=1;i=k;i++) { if((n%i)==0) { d=d+i; l=n/i; if(i!=l) d=d+l; } } printf(%lld\n,d-n); t--; } return (0); } -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adding Two no without using any operator...??
@dave well that was basically a query if it is possible to eliminate all the operators and do something like addition operation.I am sorry if I presentted my question in the wrong wayI am bad at explaining things.:( Going by your previous records I am not elibigle to contradict you. On Mon, Aug 29, 2011 at 9:02 AM, Dave dave_and_da...@juno.com wrote: @Saurabh: Function calls and commas are operators, so that leaves out your clever printf solution. See http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Other_operators. Dave On Aug 28, 9:32 pm, saurabh singh saurab...@gmail.com wrote: @dave even '=' is an operator.I wonder if its possible to restrict *all operators*. On Sun, Aug 28, 2011 at 1:32 AM, Dave dave_and_da...@juno.com wrote: @Brijesh: Maybe you mean char *p; p = (char*)a; sum = (int)p[b]; // sum = a + b but is an operator. Dave On Aug 27, 2:07 pm, Brijesh brijeshupadhyay...@gmail.com wrote: How to add two nos without using any operator...? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD- Hide quoted text - - Show quoted text - -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How to save a binary search tree space efficiently
@prashant it is the same mid value as u calculate in binary search i.e. (lowest index+highest index)/2 No matter whether it is 18 or 27,u gonna get almost balanced BST every time if u do construct the tree as ankit has mentioned. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adding Two no without using any operator...??
Awesome Saurabh. Hats off man:) On Mon, Aug 29, 2011 at 2:43 PM, saurabh singh saurab...@gmail.com wrote: @dave well that was basically a query if it is possible to eliminate all the operators and do something like addition operation.I am sorry if I presentted my question in the wrong wayI am bad at explaining things.:( Going by your previous records I am not elibigle to contradict you. On Mon, Aug 29, 2011 at 9:02 AM, Dave dave_and_da...@juno.com wrote: @Saurabh: Function calls and commas are operators, so that leaves out your clever printf solution. See http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Other_operators. Dave On Aug 28, 9:32 pm, saurabh singh saurab...@gmail.com wrote: @dave even '=' is an operator.I wonder if its possible to restrict *all operators*. On Sun, Aug 28, 2011 at 1:32 AM, Dave dave_and_da...@juno.com wrote: @Brijesh: Maybe you mean char *p; p = (char*)a; sum = (int)p[b]; // sum = a + b but is an operator. Dave On Aug 27, 2:07 pm, Brijesh brijeshupadhyay...@gmail.com wrote: How to add two nos without using any operator...? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD- Hide quoted text - - Show quoted text - -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech Computer Science And Engineering National Institute of Technology -Allahabad -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adding Two no without using any operator...??
super Thank you, Sid. On Sun, Aug 28, 2011 at 7:42 AM, saurabh singh saurab...@gmail.com wrote: main() { int a=4,b=6; printf(\n%d\n,printf(%*s%*s,a,,b,)); } -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adding Two no without using any operator...??
can you please tell me how is this working main() { int a=4,b=6; printf(\n%d\n,printf(%*s%*s,a,,b,)); } -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) -- sapraaks...@gmail.com akshatsapr...@gmail.com rit2009...@iiita.ac.in sapraaks...@facebook.com -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How to save a binary search tree space efficiently
@prateek but you wont get same tree back always .. you get only balanced tree take a look below: 9 9 \ \ 18 10 / \ \ 10 27 18 \ 27 Both are BST but this case inorder traversal wont get back original tree On Mon, Aug 29, 2011 at 3:09 PM, PRATEEK VERMA prateek...@gmail.com wrote: @prashant it is the same mid value as u calculate in binary search i.e. (lowest index+highest index)/2 No matter whether it is 18 or 27,u gonna get almost balanced BST every time if u do construct the tree as ankit has mentioned. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] String Reverse
Give an algorithm/C Code to reverse a string using a recursive function without swapping or using any extra memory? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Any PHP experts out there?
Any suggestions/references for same? have done web programming in past, but not so much creating websites with dynamic content/database integration etc. Also, i plan to start with WAMP model as i use Windows as my primary dev platform. -- Regards, Navneet -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Any PHP experts out there?
cs e75 google it Rahul On Mon, Aug 29, 2011 at 4:35 PM, Navneet Gupta navneetn...@gmail.comwrote: Any suggestions/references for same? have done web programming in past, but not so much creating websites with dynamic content/database integration etc. Also, i plan to start with WAMP model as i use Windows as my primary dev platform. -- Regards, Navneet -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explanation
Utkarsh : according to you, in second printf also, f(1,2) has to be expanded first since its value is taken by g ? Sanju :) On Mon, Aug 29, 2011 at 1:53 AM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: it is evaluated first because it's value is taken by the h function -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] NIVIO info
hi to every one.. can any one know about NIVIO and its interview procedure as it soon coming to my college. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] informatica
can anyone tell me about their procedure and written test .. plz -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Probability
An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] String Reverse
http://www.ideone.com/kSaff On Mon, Aug 29, 2011 at 4:17 PM, rohit agarwal agarwal.rohi...@gmail.comwrote: Print the last character of a string and call the function recursively with remaining string (of length (n-1)) -- * Thanks and Regards* ┌─┐ Rohit Agarwal Final Year B.Tech (Information Technology) NIT Durgapur http://www.nitdgp.ac.in └─┘ -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
is it 0.55... On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.comwrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
ur answer is correct but i hv a confusion that all four shots fire at a time so there may be probability that all shots hits the craft. but ur assuming that first hit + first not hit * second hit+.. plz clear my confustion On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.comwrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
i hv googled it and the answer is like The enemy aircraft will be brought down even if one of the four shots hits the aircraft. The opposite of this situation is that none of the four shots hit the aircraft. The probability that none of the four shots hit the aircraft is given by (1-0.7)(1-0.6)(1-0.5)(1-0.4) = 0.3*0.4*0.5*0.6 = 0.036 So, the probability that at least one of the four hits the aircraft = 1 – 0.036 = 0.964. On Mon, Aug 29, 2011 at 5:54 PM, vishwa vishwavam...@gmail.com wrote: is it 0.55... On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
It should be 1 - no one hits, i.e. 1 - 0.3*0.6*0.5*0.6 = 1 - 0.0540=0.9460. Correct me if m wrong.. Sanju :) On Mon, Aug 29, 2011 at 5:19 AM, Abhishek Yadav algowithabhis...@gmail.comwrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
i was abt to write it :) but u googled it :D On Mon, Aug 29, 2011 at 5:57 PM, Naman Mahor naman.ma...@gmail.com wrote: i hv googled it and the answer is like The enemy aircraft will be brought down even if one of the four shots hits the aircraft. The opposite of this situation is that none of the four shots hit the aircraft. The probability that none of the four shots hit the aircraft is given by (1-0.7)(1-0.6)(1-0.5)(1-0.4) = 0.3*0.4*0.5*0.6 = 0.036 So, the probability that at least one of the four hits the aircraft = 1 – 0.036 = 0.964. On Mon, Aug 29, 2011 at 5:54 PM, vishwa vishwavam...@gmail.com wrote: is it 0.55... On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
u mean to say .964 and not .946..isnt it? On Mon, Aug 29, 2011 at 5:58 PM, Sanjay Rajpal srn...@gmail.com wrote: It should be 1 - no one hits, i.e. 1 - 0.3*0.6*0.5*0.6 = 1 - 0.0540=0.9460. Correct me if m wrong.. Sanju :) On Mon, Aug 29, 2011 at 5:19 AM, Abhishek Yadav algowithabhis...@gmail.com wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
@naman: whose answer man On Mon, Aug 29, 2011 at 5:56 PM, Naman Mahor naman.ma...@gmail.com wrote: ur answer is correct but i hv a confusion that all four shots fire at a time so there may be probability that all shots hits the craft. but ur assuming that first hit + first not hit * second hit+.. plz clear my confustion On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: 2 Binary trees are isomorphic?
The definition is interpreted as either strictly isomorphic or quasi- isomorphic but technically (technically) isomorphic binary trees do not require any transformation themselves. See below link: http://www.cs.duke.edu/courses/spring00/cps100/assign/trees/ Bharath. On Aug 28, 11:53 pm, muthu raj muthura...@gmail.com wrote: In Amazon written test Isomorphic trees were defined as those in which a series of flips can transform one tree to another. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Aug 28, 2011 at 11:52 AM, bugaboo bharath.sri...@gmail.com wrote: @Navneet, What you are talking about are quasi-isomorphic trees where trees can be changed a bit (flip right/left sub-trees to be precise) to make them isomorphic. An isomorphic tree does not need any transformation, they are similar in structure by themselves. On Aug 28, 1:44 pm, Navneet navneetn...@gmail.com wrote: @Dave, From the definition of isomorphic trees(not in ques given), what i know of is that one can be transformed into another. The above three are then isomorphic to each other. @Bugaboo, can you clarify what exactly do you mean by isomorphic here? On Aug 28, 9:25 pm, Dave dave_and_da...@juno.com wrote: @Naveet: So we have a question of semantics. Do these three trees have the same structure: a / b / c and a \ b \ c and a \ b / c I say no, but perhaps you say yes. Dave On Aug 28, 9:35 am, Navneet navneetn...@gmail.com wrote: Dave, that is why i have an OR condition between. Each side of OR has two calls with AND in between. Basically at any node, you will have to invoke with two combinations ((left,left) AND (right,right) OR (left,right) AND (right,left)) Let me know if you think that's not required. On Aug 28, 6:02 pm, Dave dave_and_da...@juno.com wrote: @Navneet: Don't we want both subtrees to be isomorphic? Dave On Aug 28, 6:40 am, Navneet navneetn...@gmail.com wrote: Dave, I think the last condition should be return (AreIsomorphic(tree1-left, tree2-left) AreIsomorphic(tree1-right,tree2-right)) || (AreIsomorphic(tree1-left, tree2-right) AreIsomorphic(tree1-right,tree2-left)) On Aug 28, 3:39 pm, Ankur Garg ankurga...@gmail.com wrote: Daves solution looks cool to me...shud work :) Nice one Dave :) Regards Ankur On Sun, Aug 28, 2011 at 4:08 PM, Ankur Garg ankurga...@gmail.com wrote: cant we just count the no of nodes in each level and compare them with the second one.. if the numbers are same trees can be said to be isomorphic On Sun, Aug 28, 2011 at 3:54 AM, Dave dave_and_da...@juno.com wrote: @Bugaboo: Use recursion. Assuming struct tree_node { tree_node *left; tree_node *right; int data; }; int AreIsomorphic(tree_node tree1, tree_node tree2) { if( tree1 == NULL tree2 == NULL ) return TRUE; // both trees are null if( tree1 == NULL || tree2 == NULL) return FALSE; // one tree is null, the other is not return AreIsomorphic(tree1-left,tree2-left) AreIsomorphic(tree1-right,tree2-right); } Dave On Aug 27, 12:05 pm, bugaboo bharath.sri...@gmail.com wrote: Considering the definition of binary tree isomorphism is the following: - 2 binary trees are isomorphic if they have the same structure but differ just by values. What is the logic (or pseudo code) for checking if two binary trees are isomorphic? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.-Hidequotedtext- - Show quoted text -- Hide quoted text - - Show quoted text - -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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
Re: [algogeeks] Probability
abhishek's answer. plz clear my confusion that i hv mentioned above. On Mon, Aug 29, 2011 at 6:04 PM, vishwa vishwavam...@gmail.com wrote: @naman: whose answer man On Mon, Aug 29, 2011 at 5:56 PM, Naman Mahor naman.ma...@gmail.comwrote: ur answer is correct but i hv a confusion that all four shots fire at a time so there may be probability that all shots hits the craft. but ur assuming that first hit + first not hit * second hit+.. plz clear my confustion On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] String Reverse
void rev_str(int i) { if(i==((length/2))) return ; rev_str(i+1); SWAP(str[i],str[length-1-i],t); } passing 0 as parameter... On Mon, Aug 29, 2011 at 5:43 PM, mani walia manis...@gmail.com wrote: aa chak code #includeconio.h #includestdio.h void rev(char*); int main() { rev(hello sexy how are you); getch(); } void rev(char *t) { if(*t) { rev(t+1); } printf(%c,*t); } khush reh... lol On Mon, Aug 29, 2011 at 5:38 PM, saurabh singh saurab...@gmail.comwrote: http://www.ideone.com/kSaff On Mon, Aug 29, 2011 at 4:17 PM, rohit agarwal agarwal.rohi...@gmail.com wrote: Print the last character of a string and call the function recursively with remaining string (of length (n-1)) -- * Thanks and Regards* ┌─┐ Rohit Agarwal Final Year B.Tech (Information Technology) NIT Durgapur http://www.nitdgp.ac.in └─┘ -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
if first is hit then the probability will be 0.7he missed 1st chance ,, probability with which he missed is 0.3 ... same way he will try 2nd chance.. hit chance is 0.6.. but he missed first already.. so total probabilty of hit is 0.3*0.6... its the same way for all. On Mon, Aug 29, 2011 at 6:06 PM, Naman Mahor naman.ma...@gmail.com wrote: abhishek's answer. plz clear my confusion that i hv mentioned above. On Mon, Aug 29, 2011 at 6:04 PM, vishwa vishwavam...@gmail.com wrote: @naman: whose answer man On Mon, Aug 29, 2011 at 5:56 PM, Naman Mahor naman.ma...@gmail.comwrote: ur answer is correct but i hv a confusion that all four shots fire at a time so there may be probability that all shots hits the craft. but ur assuming that first hit + first not hit * second hit+.. plz clear my confustion On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] informatica
which collg?when its coming? On Mon, Aug 29, 2011 at 5:26 PM, mani walia manis...@gmail.com wrote: can anyone tell me about their procedure and written test .. plz -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explanation
see the out put will the help of gcc -E.u will get ur ans -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] String Reverse
use xor inplace of a swap...u wont require extra space or memory... printing isnt a solution... On Mon, Aug 29, 2011 at 6:15 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: void rev_str(int i) { if(i==((length/2))) return ; rev_str(i+1); SWAP(str[i],str[length-1-i],t); } passing 0 as parameter... On Mon, Aug 29, 2011 at 5:43 PM, mani walia manis...@gmail.com wrote: aa chak code #includeconio.h #includestdio.h void rev(char*); int main() { rev(hello sexy how are you); getch(); } void rev(char *t) { if(*t) { rev(t+1); } printf(%c,*t); } khush reh... lol On Mon, Aug 29, 2011 at 5:38 PM, saurabh singh saurab...@gmail.comwrote: http://www.ideone.com/kSaff On Mon, Aug 29, 2011 at 4:17 PM, rohit agarwal agarwal.rohi...@gmail.com wrote: Print the last character of a string and call the function recursively with remaining string (of length (n-1)) -- * Thanks and Regards* ┌─┐ Rohit Agarwal Final Year B.Tech (Information Technology) NIT Durgapur http://www.nitdgp.ac.in └─┘ -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: elitmus test
can you share some DI questionsurgent On Sun, Aug 28, 2011 at 3:37 PM, Aditya Virmani virmanisadi...@gmail.comwrote: focus on quant di...verbal wud be easy...as in our college, thr were two papers, on which had gud level of quant qns...qns were nt tough to crack, but involved calculations which may take gud amt of time...like thr was 1 qn: find the sum of first 1234 terms in the series 121221222112. its easy but calculations may be high if u dun do it wit sum trick, second paper had tougher DI but pretty easy quant...so u hav to manage ur time well... On Sun, Aug 28, 2011 at 1:00 AM, prasanna rockslife2...@gmail.com wrote: thanks...:) hope someone adds some more questions..:) -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Is This algorithm gives right answer ?? // algo to find max subarray ie whose sum is max
Kadane's Algorithm(array[1..n]) begin (maxSum, maxStartIndex, maxEndIndex) := (-INFINITY, 0, 0) currentMaxSum := 0 currentStartIndex := 1 for currentEndIndex := 1 to n do currentMaxSum := currentMaxSum + array[currentEndIndex] if currentMaxSum maxSum then (maxSum, maxStartIndex, maxEndIndex) := (currentMaxSum, currentStartIndex, currentEndIndex) endif if currentMaxSum 0 then currentMaxSum := 0 currentStartIndex := currentEndIndex + 1 endif endfor return (maxSum, maxStartIndex, maxEndIndex) end -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] informatica
Someone please share their recruitment procedure and the topics they focus on.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/nJZwHH_s2j4J. 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] String Reverse
@Dheeraj : I think the question says no swapping. On Mon, Aug 29, 2011 at 6:56 PM, Karan Thakral karanthak...@gmail.comwrote: use xor inplace of a swap...u wont require extra space or memory... printing isnt a solution... On Mon, Aug 29, 2011 at 6:15 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: void rev_str(int i) { if(i==((length/2))) return ; rev_str(i+1); SWAP(str[i],str[length-1-i],t); } passing 0 as parameter... On Mon, Aug 29, 2011 at 5:43 PM, mani walia manis...@gmail.com wrote: aa chak code #includeconio.h #includestdio.h void rev(char*); int main() { rev(hello sexy how are you); getch(); } void rev(char *t) { if(*t) { rev(t+1); } printf(%c,*t); } khush reh... lol On Mon, Aug 29, 2011 at 5:38 PM, saurabh singh saurab...@gmail.comwrote: http://www.ideone.com/kSaff On Mon, Aug 29, 2011 at 4:17 PM, rohit agarwal agarwal.rohi...@gmail.com wrote: Print the last character of a string and call the function recursively with remaining string (of length (n-1)) -- * Thanks and Regards* ┌─┐ Rohit Agarwal Final Year B.Tech (Information Technology) NIT Durgapur http://www.nitdgp.ac.in └─┘ -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc *Winners Don't do Different things , they do things Differently* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] tejas 2010 coding test
@Utkarsh- I didnt get u. Can u explain more or else it will be better if u post the code directly for it. On Mon, Aug 29, 2011 at 2:08 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: use seive or store only prime numbers in an array by squareroot method On Sun, Aug 28, 2011 at 9:15 AM, Prags onlypr...@gmail.com wrote: Q- Fibonacci series for prime no only ..there were lot of restrictions given we need to write an optimised code -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Given a number, return the least prime greater than number
That might require a very large table. There are 203 million primes less than 2^32. Because a hash function is usually established once and then used many times, computing a whole table of primes is not necessary. Finding the one next prime can be done faster using trial division, because the overhead in setting up a sieve is actually more work than just finding the one next prime with trial division, if the numbers are not huge. The function below will find the next prime for numbers less than 100 million in about half the time it takes to use a sieve. Again, trial division is not the best way to find a stream of many prime numbers, but it is just fine for finding one. Don int nextPrime(int n) { ++n; if (n % 2 == 0) ++n; if (n % 3 == 0) n += 2; int step = XEC[n%3] - 'A'; while(1) { for (int i = 5; i*i = n; i += 6) { if (n%i == 0) break; if (n%(i+2) == 0) break; } if (i*i n) return n; n += step; step ^= 6; } } On Aug 27, 3:59 am, saurabh modi saurabhmodi102...@gmail.com wrote: use sieve.then make a list of primes. A binary search can work well to find the next greater prime number. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: How to save a binary search tree space efficiently
yep, I realized the mistake. thanks for the clarification. BTW, what approach will be suitable in Bin Tree, extensible to MST . On Aug 29, 11:49 am, prashant thorat prashantnit...@gmail.com wrote: @vikas : you can use recursive approach to draw tree here we go: 6 4 3 5 7 8 11 12 1 ) 6 is root since 4 6 , 4 is left child of 6 2) find value which is more than 6 , so it is 7 in this case... hence 7 is right child. 3 ) Hence we break this list in three part; 1. Root node (6) 2. left sub tree (4,3,5) 3. right subtree (7,8,11,12) 6 / \ (4,3,5) (7,8,11,12) we repeat same 3 steps for left and right sub tree. So we need only one Preorder traversal. On Mon, Aug 29, 2011 at 1:22 AM, vikas vikas.rastogi2...@gmail.com wrote: @ Sagar, level order can be stored but you need to remember the nulls always On Aug 29, 12:06 am, sagar pareek sagarpar...@gmail.com wrote: level order traversal is best for this case :) On Sun, Aug 28, 2011 at 11:53 PM, prashant thorat prashantnit...@gmail.comwrote: only preorder will suffice.. considering fact that it's BST On Sun, Aug 28, 2011 at 11:26 PM, Rishabbh A Dua duarish...@gmail.com wrote: Please correct me if i am wrong but isnt the answer to this q is AVL trees On Sun, Aug 28, 2011 at 10:43 PM, Dhriti Khanna dhriti0...@gmail.com wrote: @ Navneet: See if the tree is: 6 4 7 3 5 8 Then the preorder traversal is : 6 4 3 5 7 8 And using this preorder traversal and inserting them in the tree one by one, we generate this exact tree. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Rishabbh A Dua -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Given a number, return the least prime greater than number
@Don I couldnot get what *int step = XEC[n%3]-'A' does* * * *can u elaborate on that* * * ... but i got your logic ... -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Given a number, return the least prime greater than number
I got it ... thanks {That line finds what value of step needs to be taken ... } Algo is good ... :D -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Custom Random Generator
@Don...Nice solution.. But the return statement should be a+b-1 On Mon, Aug 29, 2011 at 10:33 PM, Don dondod...@gmail.com wrote: If you draw the nxn grid and assign a value to each diagonal: (For n = 5) --b | 12345 | 2345 | 345 | 45 | 5 a You want the result to be the orthogonal distance from the diagonal. That is what the formula computes. Don On Aug 29, 11:28 am, Piyush Grover piyush4u.iit...@gmail.com wrote: I understand what you are doing in the loop but return statement is not clear to me. Can you explain. On Mon, Aug 29, 2011 at 9:48 PM, Don dondod...@gmail.com wrote: int custRand(int n) { int a,b; do { a = rand(n); b = rand(n); } while(a b); return n - a + b; } On Aug 29, 10:48 am, Piyush Grover piyush4u.iit...@gmail.com wrote: Given a function rand(n) which returns a random value between 1...n assuming equal probability. Write a function CustRand(n) using rand(n) which returns a value between 1...n such that the probability of occurrence of each number is proportional to its value. I have a solution but wondering if I can get better than this or some other approaches: CustRand(n){ sum = n*(n+1)/2; a = rand(sum); for(i = 1; i = n; i++){ h = i*(i+1)/2; l = i*(i-1)/2; if(a = h a l) return i; } } -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Given a number, return the least prime greater than number
Step alternates between 4 and 2 in such a way that n hits all odd values not divisible by 3. Don On Aug 29, 10:35 am, dilip makwana dilipmakwa...@gmail.com wrote: I got it ... thanks {That line finds what value of step needs to be taken ... } Algo is good ... :D -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Custom Random Generator
No...if a = b = 5 then return 9 doesn't make any sense. n - (a-b) is very much fine. for n = 5 Total # of cases when a - b = 0; 5 return 5 Total # of cases when a-b = 1; 4 return 4 Total # of cases when a-b = 2; 3 return 3 and so on. On Mon, Aug 29, 2011 at 10:56 PM, nishaanth nishaant...@gmail.com wrote: @Don...Nice solution.. But the return statement should be a+b-1 On Mon, Aug 29, 2011 at 10:33 PM, Don dondod...@gmail.com wrote: If you draw the nxn grid and assign a value to each diagonal: (For n = 5) --b | 12345 | 2345 | 345 | 45 | 5 a You want the result to be the orthogonal distance from the diagonal. That is what the formula computes. Don On Aug 29, 11:28 am, Piyush Grover piyush4u.iit...@gmail.com wrote: I understand what you are doing in the loop but return statement is not clear to me. Can you explain. On Mon, Aug 29, 2011 at 9:48 PM, Don dondod...@gmail.com wrote: int custRand(int n) { int a,b; do { a = rand(n); b = rand(n); } while(a b); return n - a + b; } On Aug 29, 10:48 am, Piyush Grover piyush4u.iit...@gmail.com wrote: Given a function rand(n) which returns a random value between 1...n assuming equal probability. Write a function CustRand(n) using rand(n) which returns a value between 1...n such that the probability of occurrence of each number is proportional to its value. I have a solution but wondering if I can get better than this or some other approaches: CustRand(n){ sum = n*(n+1)/2; a = rand(sum); for(i = 1; i = n; i++){ h = i*(i+1)/2; l = i*(i-1)/2; if(a = h a l) return i; } } -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C puzzle
@Rajeev: I had written down the recursion tree on paper but since you said that there were 10 reds and greens, I compiled the code and checked it myself. I'm afraid you are wrong my friend. The correct answer is indeed 6 RED and 10 GREEN calls. -- Anup Ghatage -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C puzzle
@Anup : I think you should also try to compile and check the answer... May be I am wrong But compiler won't On Mon, Aug 29, 2011 at 11:02 PM, Anup Ghatage ghat...@gmail.com wrote: @Rajeev: I had written down the recursion tree on paper but since you said that there were 10 reds and greens, I compiled the code and checked it myself. I'm afraid you are wrong my friend. The correct answer is indeed 6 RED and 10 GREEN calls. -- Anup Ghatage -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc *Winners Don't do Different things , they do things Differently* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Custom Random Generator
No, a+b-1 would return values outside of the desired range. Don On Aug 29, 12:26 pm, nishaanth nishaant...@gmail.com wrote: @Don...Nice solution.. But the return statement should be a+b-1 On Mon, Aug 29, 2011 at 10:33 PM, Don dondod...@gmail.com wrote: If you draw the nxn grid and assign a value to each diagonal: (For n = 5) --b | 12345 | 2345 | 345 | 45 | 5 a You want the result to be the orthogonal distance from the diagonal. That is what the formula computes. Don On Aug 29, 11:28 am, Piyush Grover piyush4u.iit...@gmail.com wrote: I understand what you are doing in the loop but return statement is not clear to me. Can you explain. On Mon, Aug 29, 2011 at 9:48 PM, Don dondod...@gmail.com wrote: int custRand(int n) { int a,b; do { a = rand(n); b = rand(n); } while(a b); return n - a + b; } On Aug 29, 10:48 am, Piyush Grover piyush4u.iit...@gmail.com wrote: Given a function rand(n) which returns a random value between 1...n assuming equal probability. Write a function CustRand(n) using rand(n) which returns a value between 1...n such that the probability of occurrence of each number is proportional to its value. I have a solution but wondering if I can get better than this or some other approaches: CustRand(n){ sum = n*(n+1)/2; a = rand(sum); for(i = 1; i = n; i++){ h = i*(i+1)/2; l = i*(i-1)/2; if(a = h a l) return i; } } -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How to save a binary search tree space efficiently
@vikas: in case of BT u can save it using BFS and construct it back .. On Mon, Aug 29, 2011 at 8:42 PM, vikas vikas.rastogi2...@gmail.com wrote: yep, I realized the mistake. thanks for the clarification. BTW, what approach will be suitable in Bin Tree, extensible to MST . On Aug 29, 11:49 am, prashant thorat prashantnit...@gmail.com wrote: @vikas : you can use recursive approach to draw tree here we go: 6 4 3 5 7 8 11 12 1 ) 6 is root since 4 6 , 4 is left child of 6 2) find value which is more than 6 , so it is 7 in this case... hence 7 is right child. 3 ) Hence we break this list in three part; 1. Root node (6)2. left sub tree (4,3,5) 3. right subtree (7,8,11,12) 6 / \ (4,3,5) (7,8,11,12) we repeat same 3 steps for left and right sub tree. So we need only one Preorder traversal. On Mon, Aug 29, 2011 at 1:22 AM, vikas vikas.rastogi2...@gmail.com wrote: @ Sagar, level order can be stored but you need to remember the nulls always On Aug 29, 12:06 am, sagar pareek sagarpar...@gmail.com wrote: level order traversal is best for this case :) On Sun, Aug 28, 2011 at 11:53 PM, prashant thorat prashantnit...@gmail.comwrote: only preorder will suffice.. considering fact that it's BST On Sun, Aug 28, 2011 at 11:26 PM, Rishabbh A Dua duarish...@gmail.com wrote: Please correct me if i am wrong but isnt the answer to this q is AVL trees On Sun, Aug 28, 2011 at 10:43 PM, Dhriti Khanna dhriti0...@gmail.com wrote: @ Navneet: See if the tree is: 6 4 7 3 5 8 Then the preorder traversal is : 6 4 3 5 7 8 And using this preorder traversal and inserting them in the tree one by one, we generate this exact tree. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Rishabbh A Dua -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Yours affectionately, Prashant Thorat Computer Science and Engg. Dept, NIT Durgapur. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: 2 Binary trees are isomorphic?
@Dave: thanks. Knew it wasn't as simple as that. Any other solution you can think of? On Aug 29, 12:46 pm, Dave dave_and_da...@juno.com wrote: @Bugaboo: No. Consider these trees: a / \ b c / \ d e / \ f g a / \ b c / \ d e / \ f g Dave On Aug 29, 10:37 am, bugaboo bharath.sri...@gmail.com wrote: The question I originally asked was meant for strict isomorphic trees. Now, let's assume the trees can be quasi-isomorphic, i.e 2 binary trees are called quasi-isomorphic if they have the same structure after flipping any of the right/left sub-trees any number of times. How do you do it? My initial solution which appears seemingly simple but can't come up with a test case that fails. - Count the number of nodes at every level for both trees. If they are the same, then they are quasi-isomorphic. I know this is a necessary condition but is this sufficient as well? On Aug 29, 7:37 am, bugaboo bharath.sri...@gmail.com wrote: The definition is interpreted as either strictly isomorphic or quasi- isomorphic but technically (technically) isomorphic binary trees do not require any transformation themselves. See below link:http://www.cs.duke.edu/courses/spring00/cps100/assign/trees/ Bharath. On Aug 28, 11:53 pm, muthu raj muthura...@gmail.com wrote: In Amazon written test Isomorphic trees were defined as those in which a series of flips can transform one tree to another. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Aug 28, 2011 at 11:52 AM,bugaboobharath.sri...@gmail.com wrote: @Navneet, What you are talking about are quasi-isomorphic trees where trees can be changed a bit (flip right/left sub-trees to be precise) to make them isomorphic. An isomorphic tree does not need any transformation, they are similar in structure by themselves. On Aug 28, 1:44 pm, Navneet navneetn...@gmail.com wrote: @Dave, From the definition of isomorphic trees(not in ques given), what i know of is that one can be transformed into another. The above three are then isomorphic to each other. @Bugaboo, can you clarify what exactly do you mean by isomorphic here? On Aug 28, 9:25 pm, Dave dave_and_da...@juno.com wrote: @Naveet: So we have a question of semantics. Do these three trees have the same structure: a / b / c and a \ b \ c and a \ b / c I say no, but perhaps you say yes. Dave On Aug 28, 9:35 am, Navneet navneetn...@gmail.com wrote: Dave, that is why i have an OR condition between. Each side of OR has two calls with AND in between. Basically at any node, you will have to invoke with two combinations ((left,left) AND (right,right) OR (left,right) AND (right,left)) Let me know if you think that's not required. On Aug 28, 6:02 pm, Dave dave_and_da...@juno.com wrote: @Navneet: Don't we want both subtrees to be isomorphic? Dave On Aug 28, 6:40 am, Navneet navneetn...@gmail.com wrote: Dave, I think the last condition should be return (AreIsomorphic(tree1-left, tree2-left) AreIsomorphic(tree1-right,tree2-right)) || (AreIsomorphic(tree1-left, tree2-right) AreIsomorphic(tree1-right,tree2-left)) On Aug 28, 3:39 pm, Ankur Garg ankurga...@gmail.com wrote: Daves solution looks cool to me...shud work :) Nice one Dave :) Regards Ankur On Sun, Aug 28, 2011 at 4:08 PM, Ankur Garg ankurga...@gmail.com wrote: cant we just count the no of nodes in each level and compare them with the second one.. if the numbers are same trees can be said to be isomorphic On Sun, Aug 28, 2011 at 3:54 AM, Dave dave_and_da...@juno.com wrote: @Bugaboo: Use recursion. Assuming struct tree_node { tree_node *left; tree_node *right; int data; }; int AreIsomorphic(tree_node tree1, tree_node tree2) { if( tree1 == NULL tree2 == NULL ) return TRUE; // both trees are null if( tree1 == NULL || tree2 == NULL) return FALSE; // one tree is null, the other is not return AreIsomorphic(tree1-left,tree2-left) AreIsomorphic(tree1-right,tree2-right); } Dave On Aug 27, 12:05 pm,bugaboobharath.sri...@gmail.com wrote:
Re: [algogeeks] Re: Custom Random Generator
Total # of cases when a - b = 0; 5 return 5 Total # of cases when a-b = 1; 4 return 4 Total # of cases when a-b = 2; 3 return 3 Sorry, it is misleading...it should be Total # of cases when a - b = 0; 5 return 5 is probable 5 times Total # of cases when a-b = 1; 4 return 4 is probable 4 times Total # of cases when a-b = 2; 3 return 3 is probable 3 times and so on... On Mon, Aug 29, 2011 at 11:17 PM, Don dondod...@gmail.com wrote: No, a+b-1 would return values outside of the desired range. Don On Aug 29, 12:26 pm, nishaanth nishaant...@gmail.com wrote: @Don...Nice solution.. But the return statement should be a+b-1 On Mon, Aug 29, 2011 at 10:33 PM, Don dondod...@gmail.com wrote: If you draw the nxn grid and assign a value to each diagonal: (For n = 5) --b | 12345 | 2345 | 345 | 45 | 5 a You want the result to be the orthogonal distance from the diagonal. That is what the formula computes. Don On Aug 29, 11:28 am, Piyush Grover piyush4u.iit...@gmail.com wrote: I understand what you are doing in the loop but return statement is not clear to me. Can you explain. On Mon, Aug 29, 2011 at 9:48 PM, Don dondod...@gmail.com wrote: int custRand(int n) { int a,b; do { a = rand(n); b = rand(n); } while(a b); return n - a + b; } On Aug 29, 10:48 am, Piyush Grover piyush4u.iit...@gmail.com wrote: Given a function rand(n) which returns a random value between 1...n assuming equal probability. Write a function CustRand(n) using rand(n) which returns a value between 1...n such that the probability of occurrence of each number is proportional to its value. I have a solution but wondering if I can get better than this or some other approaches: CustRand(n){ sum = n*(n+1)/2; a = rand(sum); for(i = 1; i = n; i++){ h = i*(i+1)/2; l = i*(i-1)/2; if(a = h a l) return i; } } -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C puzzle
@Anup Can u pls explain the program ? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] String Reverse
void function(int start, int end){ if (start end) return; int x= a[end]-a[start]; a[start] = a[start] + x; a[end] = a[end] - x; function(start+1, end-1); } main(){ scanf(%s, a[0]); int len = strlen(a); function(0,len-1); printf(%s\n, a); } -- Ankit Agarwal Computer Science Engg. Integrated Dual Degree, V yr Department of Electronics Computer Engineering Indian Institute of Technology Roorkee Ph. no. +91-9580098805 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C puzzle
http://ideone.com/o4r4o but it is calling red and green just two times each.. On Mon, Aug 29, 2011 at 11:06 PM, rajeev bharshetty rajeevr...@gmail.comwrote: @Anup : I think you should also try to compile and check the answer... May be I am wrong But compiler won't On Mon, Aug 29, 2011 at 11:02 PM, Anup Ghatage ghat...@gmail.com wrote: @Rajeev: I had written down the recursion tree on paper but since you said that there were 10 reds and greens, I compiled the code and checked it myself. I'm afraid you are wrong my friend. The correct answer is indeed 6 RED and 10 GREEN calls. -- Anup Ghatage -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc *Winners Don't do Different things , they do things Differently* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: 2 Binary trees are isomorphic?
Would this work: boolean IsQuasiIsomorphic(Node x, Node y) { if (x == null y == null) return true // both null if (x == null || y == null) return false // exactly one null //Else, the left sub-tree of tree 1 is isomorphic to the left or right subtree of tree 2 return ( ( IsQuasiIsomorphic(x.left, y.left) OR IsQuasiIsomorphic(x.left, y.right)) AND ( IsQuasiIsomorphic(x.right, y.right) OR IsQuasiIsomorphic(x.right, y.left) )) } On Mon, Aug 29, 2011 at 12:53 PM, bugaboo bharath.sri...@gmail.com wrote: @Dave: thanks. Knew it wasn't as simple as that. Any other solution you can think of? On Aug 29, 12:46 pm, Dave dave_and_da...@juno.com wrote: @Bugaboo: No. Consider these trees: a / \ b c / \ d e / \ fg a / \ b c / \ d e / \ fg Dave On Aug 29, 10:37 am, bugaboo bharath.sri...@gmail.com wrote: The question I originally asked was meant for strict isomorphic trees. Now, let's assume the trees can be quasi-isomorphic, i.e 2 binary trees are called quasi-isomorphic if they have the same structure after flipping any of the right/left sub-trees any number of times. How do you do it? My initial solution which appears seemingly simple but can't come up with a test case that fails. - Count the number of nodes at every level for both trees. If they are the same, then they are quasi-isomorphic. I know this is a necessary condition but is this sufficient as well? On Aug 29, 7:37 am, bugaboo bharath.sri...@gmail.com wrote: The definition is interpreted as either strictly isomorphic or quasi- isomorphic but technically (technically) isomorphic binary trees do not require any transformation themselves. See below link: http://www.cs.duke.edu/courses/spring00/cps100/assign/trees/ Bharath. On Aug 28, 11:53 pm, muthu raj muthura...@gmail.com wrote: In Amazon written test Isomorphic trees were defined as those in which a series of flips can transform one tree to another. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Aug 28, 2011 at 11:52 AM,bugaboobharath.sri...@gmail.com wrote: @Navneet, What you are talking about are quasi-isomorphic trees where trees can be changed a bit (flip right/left sub-trees to be precise) to make them isomorphic. An isomorphic tree does not need any transformation, they are similar in structure by themselves. On Aug 28, 1:44 pm, Navneet navneetn...@gmail.com wrote: @Dave, From the definition of isomorphic trees(not in ques given), what i know of is that one can be transformed into another. The above three are then isomorphic to each other. @Bugaboo, can you clarify what exactly do you mean by isomorphic here? On Aug 28, 9:25 pm, Dave dave_and_da...@juno.com wrote: @Naveet: So we have a question of semantics. Do these three trees have the same structure: a / b / c and a \ b \ c and a \ b / c I say no, but perhaps you say yes. Dave On Aug 28, 9:35 am, Navneet navneetn...@gmail.com wrote: Dave, that is why i have an OR condition between. Each side of OR has two calls with AND in between. Basically at any node, you will have to invoke with two combinations ((left,left) AND (right,right) OR (left,right) AND (right,left)) Let me know if you think that's not required. On Aug 28, 6:02 pm, Dave dave_and_da...@juno.com wrote: @Navneet: Don't we want both subtrees to be isomorphic? Dave On Aug 28, 6:40 am, Navneet navneetn...@gmail.com wrote: Dave, I think the last condition should be return (AreIsomorphic(tree1-left, tree2-left) AreIsomorphic(tree1-right,tree2-right)) || (AreIsomorphic(tree1-left, tree2-right) AreIsomorphic(tree1-right,tree2-left)) On Aug 28, 3:39 pm, Ankur Garg ankurga...@gmail.com wrote: Daves solution looks cool to me...shud work :) Nice one Dave :) Regards Ankur On Sun, Aug 28, 2011 at 4:08 PM, Ankur Garg ankurga...@gmail.com wrote: cant we just count the no of nodes in each level and compare them with the second one.. if the numbers are same trees can be said to be isomorphic On Sun, Aug 28, 2011 at 3:54 AM, Dave dave_and_da...@juno.com wrote: @Bugaboo: Use recursion. Assuming struct tree_node { tree_node
[algogeeks] Re: Winshuttle Interview Questions
Yaar second question thoda elaborate kar.. didn't get it ! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/3ClTQN8-GBEJ. 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Probability
yes .964 easy hai yaar On Mon, Aug 29, 2011 at 5:47 AM, vishwa vishwavam...@gmail.com wrote: if first is hit then the probability will be 0.7he missed 1st chance ,, probability with which he missed is 0.3 ... same way he will try 2nd chance.. hit chance is 0.6.. but he missed first already.. so total probabilty of hit is 0.3*0.6... its the same way for all. On Mon, Aug 29, 2011 at 6:06 PM, Naman Mahor naman.ma...@gmail.comwrote: abhishek's answer. plz clear my confusion that i hv mentioned above. On Mon, Aug 29, 2011 at 6:04 PM, vishwa vishwavam...@gmail.com wrote: @naman: whose answer man On Mon, Aug 29, 2011 at 5:56 PM, Naman Mahor naman.ma...@gmail.comwrote: ur answer is correct but i hv a confusion that all four shots fire at a time so there may be probability that all shots hits the craft. but ur assuming that first hit + first not hit * second hit+.. plz clear my confustion On Mon, Aug 29, 2011 at 5:49 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: 2 Binary trees are isomorphic?
@Bharath: I don't think your test works. Suppose y.left is isomorphic to both x.left and x.right. Then you would return true, but you don't know that y.right is isomorphic to anything. You want (Left1 isomorphic with Left2 and Right1 isomorphic with Right2) or (Left1 isomorphic with Right2) and (RIght1 isomorphic with Left2). That's what Navneet proposed in http://groups.google.com/group/algogeeks/msg/39ae100db5588093. Dave On Aug 29, 1:43 pm, bharath sriram bharath.sri...@gmail.com wrote: Would this work: boolean IsQuasiIsomorphic(Node x, Node y) { if (x == null y == null) return true // both null if (x == null || y == null) return false // exactly one null //Else, the left sub-tree of tree 1 is isomorphic to the left or right subtree of tree 2 return ( ( IsQuasiIsomorphic(x.left, y.left) OR IsQuasiIsomorphic(x.left, y.right)) AND ( IsQuasiIsomorphic(x.right, y.right) OR IsQuasiIsomorphic(x.right, y.left) )) } On Mon, Aug 29, 2011 at 12:53 PM, bugaboo bharath.sri...@gmail.com wrote: @Dave: thanks. Knew it wasn't as simple as that. Any other solution you can think of? On Aug 29, 12:46 pm, Dave dave_and_da...@juno.com wrote: @Bugaboo: No. Consider these trees: a / \ b c / \ d e / \ f g a / \ b c / \ d e / \ f g Dave On Aug 29, 10:37 am, bugaboo bharath.sri...@gmail.com wrote: The question I originally asked was meant for strict isomorphic trees. Now, let's assume the trees can be quasi-isomorphic, i.e 2 binary trees are called quasi-isomorphic if they have the same structure after flipping any of the right/left sub-trees any number of times. How do you do it? My initial solution which appears seemingly simple but can't come up with a test case that fails. - Count the number of nodes at every level for both trees. If they are the same, then they are quasi-isomorphic. I know this is a necessary condition but is this sufficient as well? On Aug 29, 7:37 am, bugaboo bharath.sri...@gmail.com wrote: The definition is interpreted as either strictly isomorphic or quasi- isomorphic but technically (technically) isomorphic binary trees do not require any transformation themselves. See below link: http://www.cs.duke.edu/courses/spring00/cps100/assign/trees/ Bharath. On Aug 28, 11:53 pm, muthu raj muthura...@gmail.com wrote: In Amazon written test Isomorphic trees were defined as those in which a series of flips can transform one tree to another. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Aug 28, 2011 at 11:52 AM,bugaboobharath.sri...@gmail.com wrote: @Navneet, What you are talking about are quasi-isomorphic trees where trees can be changed a bit (flip right/left sub-trees to be precise) to make them isomorphic. An isomorphic tree does not need any transformation, they are similar in structure by themselves. On Aug 28, 1:44 pm, Navneet navneetn...@gmail.com wrote: @Dave, From the definition of isomorphic trees(not in ques given), what i know of is that one can be transformed into another. The above three are then isomorphic to each other. @Bugaboo, can you clarify what exactly do you mean by isomorphic here? On Aug 28, 9:25 pm, Dave dave_and_da...@juno.com wrote: @Naveet: So we have a question of semantics. Do these three trees have the same structure: a / b / c and a \ b \ c and a \ b / c I say no, but perhaps you say yes. Dave On Aug 28, 9:35 am, Navneet navneetn...@gmail.com wrote: Dave, that is why i have an OR condition between. Each side of OR has two calls with AND in between. Basically at any node, you will have to invoke with two combinations ((left,left) AND (right,right) OR (left,right) AND (right,left)) Let me know if you think that's not required. On Aug 28, 6:02 pm, Dave dave_and_da...@juno.com wrote: @Navneet: Don't we want both subtrees to be isomorphic? Dave On Aug 28, 6:40 am, Navneet navneetn...@gmail.com wrote: Dave, I think the last condition should be return (AreIsomorphic(tree1-left, tree2-left) AreIsomorphic(tree1-right,tree2-right)) || (AreIsomorphic(tree1-left, tree2-right) AreIsomorphic(tree1-right,tree2-left)) On Aug 28, 3:39 pm, Ankur Garg ankurga...@gmail.com wrote: Daves solution looks cool to me...shud work
[algogeeks] Re: How to save a binary search tree space efficiently
I'm not sure if this is what you are looking for, but I once came up with a way to save a binary tree in such a way that when it is rebuilt, it will be balanced. You don't get back the exact same tree with all the nodes in the same position, but you do get the same nodes in a balanced configuration. Start by doing an inorder traversal and storing each node sequentially in an array. Then call a recursive function called saveTree(first, last), where first and last are the first and last indices of the array. saveTree does the following if: write middle item of array to the file call saveTree on left half of array call saveTree on right half of array When you rebuild the tree adding the nodes in the order in which they occur in the file, the resulting tree will be balanced. Don On Aug 28, 1:29 am, rohit rajuljain...@gmail.com wrote: How to save a binary search tree space efficiently and built it again , just tell any idea. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] URGENT- Software engineers - Java / J2ee...Need LOCALS !!
*URGENT- Software engineers - Java / J2ee!! MAX $45/Hr...Need LOCALS (Face to Face Required)* -After TS Second round of interviews will be F2F! This position is located outside the Philadelphia area and is a long term contract. Philadelphia, PA Long Term Contract ** *Description:* Seeking bright, motivated Software Engineers to work as a member of the Java/J2EE-based product engineering teams. *Please send all resumes to **ka...@itbrainiac.com* ka...@itbrainiac.com Thanks, Katie - Staffing Manager 201-855-4204 ka...@itbrainiac.com -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Find all the subsets whose sum = k
http://mathoverflow.net/questions/57371/find-all-maximal-subsets-of-a-set-of-integers-whose-sum-does-not-exceed-a-number actual question is this. On Sat, Aug 27, 2011 at 9:56 AM, rahul sharma rahul23111...@gmail.comwrote: yeah i wen first post answer i said it is for finding sum=k; n just add one more condition in loop for finding k; i.e. if(sub+a[i]k) return sub,a[i]; is it fine nw? On Sat, Aug 27, 2011 at 7:55 AM, raj kumar megamonste...@gmail.comwrote: It's not knapsack in knapsack we find max or min subset here we have to find all subsets =k not just one which is min or max , so I guess we have to form all subsets and check their sum hence the algoritm will be 0(2^n) where n is number of elements in the set , se correct me if i am wrong or a better solution exists thanks -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] subset with sum
is there exist an approach to find subset with a particular sum in less than O(2^n) -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: subset with sum
Sort the array and use dynamic programming.. it will take at most n^2 complexity.! BY dynamic programming , i mean make a 3D type array.. which will give all the combination which sums to all the nos.. try it! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/qyurZAc9r4wJ. 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] max sum in submatrix
given a matrix with +ve and -ve numbers find the sub matrix with max sum -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: subset with sum
can u elaborate ur answer pls On Mon, Aug 29, 2011 at 12:47 PM, Brijesh brijeshupadhyay...@gmail.comwrote: Sort the array and use dynamic programming.. it will take at most n^2 complexity.! BY dynamic programming , i mean make a 3D type array.. which will give all the combination which sums to all the nos.. try it! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/qyurZAc9r4wJ. 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] URGENT- Software engineers - Java / J2ee...Need LOCALS !!
Hi PFA my resume for the below position Regards Ankur On Tue, Aug 30, 2011 at 1:00 AM, katie williams katiewilliams...@gmail.comwrote: *URGENT- Software engineers - Java / J2ee!! MAX $45/Hr...Need LOCALS (Face to Face Required)* -After TS Second round of interviews will be F2F! This position is located outside the Philadelphia area and is a long term contract. Philadelphia, PA Long Term Contract ** *Description:* Seeking bright, motivated Software Engineers to work as a member of the Java/J2EE-based product engineering teams. *Please send all resumes to **ka...@itbrainiac.com*ka...@itbrainiac.com Thanks, Katie - Staffing Manager 201-855-4204 ka...@itbrainiac.com -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. AnkurGargResume.doc Description: MS-Word document
Re: [algogeeks] URGENT- Software engineers - Java / J2ee...Need LOCALS !!
are u carzy replying such spams and putting ur resume on public forum On Mon, Aug 29, 2011 at 12:52 PM, Ankur Garg ankurga...@gmail.com wrote: Hi PFA my resume for the below position Regards Ankur On Tue, Aug 30, 2011 at 1:00 AM, katie williams katiewilliams...@gmail.com wrote: *URGENT- Software engineers - Java / J2ee!! MAX $45/Hr...Need LOCALS (Face to Face Required)* -After TS Second round of interviews will be F2F! This position is located outside the Philadelphia area and is a long term contract. Philadelphia, PA Long Term Contract ** *Description:* Seeking bright, motivated Software Engineers to work as a member of the Java/J2EE-based product engineering teams. *Please send all resumes to **ka...@itbrainiac.com*ka...@itbrainiac.com Thanks, Katie - Staffing Manager 201-855-4204 ka...@itbrainiac.com -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Custom Random Generator
Here is how to do it with a single call to rand and no looping. int custRand(int n) { int a = rand(n*n+n); int b = a / n; a %= n; return (b a) ? n+a-b+1 : n-a+b; } On Aug 29, 10:48 am, Piyush Grover piyush4u.iit...@gmail.com wrote: Given a function rand(n) which returns a random value between 1...n assuming equal probability. Write a function CustRand(n) using rand(n) which returns a value between 1...n such that the probability of occurrence of each number is proportional to its value. I have a solution but wondering if I can get better than this or some other approaches: CustRand(n){ sum = n*(n+1)/2; a = rand(sum); for(i = 1; i = n; i++){ h = i*(i+1)/2; l = i*(i-1)/2; if(a = h a l) return i; } } -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complexity.
There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complexity. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: probability ques
Agree with Don. But what if we want to find probability of on real line? How we can consider R as sample space? Is that Sample space should be COUNTABLE and FINITE? *By the quadratic formula, a is 2.08712 or 47.9128. The range is 45.8256. A falls in the range of 1..100 or 99. So the probability is 47.9128/99* * * *Here you are considering Sample space as length of the interval, right? but i think it should be cardinal({x/x belongs to Q and x belongs to [1,100]}).* On Fri, Aug 26, 2011 at 2:04 AM, Aditya Virmani virmanisadi...@gmail.comwrote: +1 Don... nthin is specified fr the nature of numbers if thy can be rational or thy hav to be only natural/integral numbers... On Wed, Aug 24, 2011 at 9:33 PM, Don dondod...@gmail.com wrote: First find the endpoints of the region where the condition is met: a + 100/a = 50 a^2 - 50a + 100 = 0 By the quadratic formula, a is 2.08712 or 47.9128. The range is 45.8256. A falls in the range of 1..100 or 99. So the probability is 47.9128/99 = 0.48397 Don On Aug 23, 11:56 am, ramya reddy rmy.re...@gmail.com wrote: Let 'a' be a number between 1 and 100. what is the probability of choosing 'a' such that a+ (100/a) 50 -- Regards Ramya * * *Try to learn something about everything and everything about something* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complex
@Tech: Let the array be a[n] and the number you are searching for be x. It is going to take at least abs( a[i] - x ) steps from the current position before a[i] can possibly equal x. Therefore, int searchStepArray( int x, int n, int a[]) { int i=0; while( i n a[i] != x ) i += abs( a[i] - x ); return i n ? i : -1 // return -1 for failure } Dave On Aug 29, 10:54 pm, tech coder techcoderonw...@gmail.com wrote: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complexity. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: probability ques
@AnikKumar: Most people normally wouldn't have difficulty with probabilities on the real numbers. E.g., there is a target with two regions, the bullseye with radius 1 and a concentric region with radius 2. What is the probability of a randomly-thrown dart hitting the bullseye, given that it hits the target? Most people would say that since the area of the bullseye is 1/4 the area of the target, the probability is 1/4. Wouldn't you say that, too? Dave On Aug 29, 11:15 pm, AnilKumar B akumarb2...@gmail.com wrote: Agree with Don. But what if we want to find probability of on real line? How we can consider R as sample space? Is that Sample space should be COUNTABLE and FINITE? *By the quadratic formula, a is 2.08712 or 47.9128. The range is 45.8256. A falls in the range of 1..100 or 99. So the probability is 47.9128/99* * * *Here you are considering Sample space as length of the interval, right? but i think it should be cardinal({x/x belongs to Q and x belongs to [1,100]}).* On Fri, Aug 26, 2011 at 2:04 AM, Aditya Virmani virmanisadi...@gmail.comwrote: +1 Don... nthin is specified fr the nature of numbers if thy can be rational or thy hav to be only natural/integral numbers... On Wed, Aug 24, 2011 at 9:33 PM, Don dondod...@gmail.com wrote: First find the endpoints of the region where the condition is met: a + 100/a = 50 a^2 - 50a + 100 = 0 By the quadratic formula, a is 2.08712 or 47.9128. The range is 45.8256. A falls in the range of 1..100 or 99. So the probability is 47.9128/99 = 0.48397 Don On Aug 23, 11:56 am, ramya reddy rmy.re...@gmail.com wrote: Let 'a' be a number between 1 and 100. what is the probability of choosing 'a' such that a+ (100/a) 50 -- Regards Ramya * * *Try to learn something about everything and everything about something* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: probability ques
Hi Guys, Comment required from NIT Warangal ppls. Who is this guy?? Who claims this ... http://timesofindia.indiatimes.com/tech/careers/job-trends/Facebook-hires-NIT-Warangal-student-for-Rs-45-lakh/articleshow/9793300.cms -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum com
@tech Could you give an example for this? If I've understood the question correctly, if we are not allowed duplicates in the array the array turns out to be sorted. If we are allowed duplicates, do we return the first occurrence ? @Dave What would be the complexity of your solution? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum com
an example array 35,36,37,36,37,38,39,40,39,40,41,42,43,42 etc array need not to be sorted. the complexity of Dave algo is O(N) in worst case , when element is not present in the array.m i right Dave On Tue, Aug 30, 2011 at 11:02 AM, Anup Ghatage ghat...@gmail.com wrote: @tech Could you give an example for this? If I've understood the question correctly, if we are not allowed duplicates in the array the array turns out to be sorted. If we are allowed duplicates, do we return the first occurrence ? @Dave What would be the complexity of your solution? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] convert a string into another in minimum number of steps
convert a string into another in minimum number of steps. insertion of a new character , deletion will be considerd as a step. for ex. to convert map into man requires 1 step. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complex
@Anup: It is O(n). The worst case is a[] = {1,2,1,2,1,2,1,2,1,2,...,1,2,1,2,1,0} where you are searching for x = 0. It will take n/2 steps. The best case is a[] = {n, n-1, n-2, ..., 1,0}, in which case it will take 1 step. Dave On Aug 30, 12:32 am, Anup Ghatage ghat...@gmail.com wrote: @tech Could you give an example for this? If I've understood the question correctly, if we are not allowed duplicates in the array the array turns out to be sorted. If we are allowed duplicates, do we return the first occurrence ? @Dave What would be the complexity of your solution? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum com
@Dave Your algo's average case working should be better than a naive O(n).. -- Anup Ghatage -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] convert a string into another in minimum number of steps
Possibly a case of finding the longest common sub-sequence and then doing the insertions/deletions etc or AKA Levenshtein distance / Edit Distance -- Anup Ghatage -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.