[algogeeks] find a point closest to other points
Given N points(in 2D) with x and y coordinates. You have to find a point P (in N given points) such that the sum of distances from other(N-1) points to P is minimum. -- Regards The Coder -- 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] determine if a string if of form pZq
determine whether the given string is of form pZq. p and q can contain only X and Y. like if p=XXYX then z will be XYXX for ex XXYXXXYXX is valid the limitation is that you can read only the next character at each point . -- Regards The Coder -- 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] MYSIS AND DRISHTI-SOFT
which other group u people are talking about, i would like to join that group. On Tue, Dec 13, 2011 at 9:21 PM, sunny agrawal sunny816.i...@gmail.comwrote: @aayush Lots of member are here but that doesn't mean that you should start posting the things which are strictly banned on this group. I hope you will take care next time while posting anything in this group. On Tue, Dec 13, 2011 at 7:40 PM, rahul sharma rahul23111...@gmail.comwrote: On Tue, Dec 13, 2011 at 3:21 PM, hary rathor harry.rat...@gmail.comwrote: aal puzzle from techinterview. more then 50 % came from there . -- 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. @aayush all the memebers approx. have joined both the groups -- 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. -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: Nice question
I tried the problem and written the code for it . it is in java. it is printing all the possible numbers I am treating the differences ans an array of integers. here is the code public class Main { public static void main(String[] args) { int digit[]={3,2,5,1};// array of absolute differences int digit[]={3,2,5,1}; for(int num=1;num=9;num++) // call with all possible initial numbers findNumber(digit,4,num,0,num); } public static void findNumber(int digit[],int n,int num,int i,int oldDigit) { if(i==n) { System.out.print(num+ ); return; } { int o=digit[i]+oldDigit; if(o10) findNumber(digit,n,10*num+o,i+1,o); o=oldDigit-digit[i]; if(o0) findNumber(digit,n,10*num+o,i+1,o); } } } and here is the output 14612 14278 14276 25723 25721 25389 25387 36834 36832 36498 47945 47943 41389 41387 58612 52498 69723 69721 63167 63165 74612 74278 74276 85723 85721 85389 85387 96834 96832 96498 BUILD SUCCESSFUL (total time: 0 seconds) On Tue, Dec 13, 2011 at 11:11 PM, Dave dave_and_da...@juno.com wrote: @Amir: Presumably, since these are digits in a number, they are bounded on the bottom by 0 and on the top by radix-1. So in decimal, if a digit is 7 and the absolute difference between it and the next digit is 3, there is only one possibility for the next digit, 7-3 = 4, since 7+3 is too large. So only some subset of the 2^(n-1) combinations of addition and subtraction may be possible. Dave On Dec 13, 4:15 am, Amir hossein Shahriari amir.hossein.shahri...@gmail.com wrote: actually there are infinite number of sequences that match it for example if the absolute differences are 3 2 5 1 one possible sequence is 6 3 5 0 1 one other is 7 4 6 1 2 or 8 5 7 2 3 and you can add any integer value to all elements and the result will still be valid actually you can start with any number and and then the second number will be equal to the first number that you chose plus/minus the first absolute difference and so on so if we are given the first element of the sequence there are 2^(n-1) ways to find a valid sequence because for each absolute difference we can either add the absolute difference to the last sequence element or subtract the absolute difference from it On Mon, Dec 12, 2011 at 9:01 PM, KAY amulya.manches...@gmail.com wrote: If for a number n digits long, the absolute difference between adjacent digits is given, how to find out the number of different numbers with these absolute differences ? for eg, if n=5 and the absolute differences are 3 2 5 1 then 1 possible number is 6 3 5 0 1(because |6-3|=3,|3-5|=2 and so on...) How many such numbers will be there? -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: Nice question
thanks don , i got it , it was due the condition in if expression . modified code i have highlighted the change public class Main { public static void main(String[] args) { int digit[]={3,2,5,1}; for(int num=1;num=9;num++) findNumber(digit,4,num,0,num); } public static void findNumber(int digit[],int n,int num,int i,int oldDigit) { if(i==n) { System.out.print(num+ ); return; } { int o=digit[i]+oldDigit; if(o10) findNumber(digit,n,10*num+o,i+1,o); o=oldDigit-digit[i]; if(o=0) // change done findNumber(digit,n,10*num+o,i+1,o); } } } output is 14612 14610 14278 14276 25723 25721 25389 25387 36834 36832 36498 30278 30276 47945 47943 47501 41389 41387 58612 58610 52498 52056 52054 69723 69721 63501 63167 63165 74612 74610 74278 74276 85723 85721 85389 85387 96834 96832 96498 BUILD SUCCESSFUL (total time: 1 second) now it's ok DON On Wed, Dec 14, 2011 at 12:50 AM, Don dondod...@gmail.com wrote: There should be 39 combinations with that input. You are missing numbers which include the digit zero, such as 14610, 30278, and 52056. Don On Dec 13, 11:37 am, tech coder techcoderonw...@gmail.com wrote: I tried the problem and written the code for it . it is in java. it is printing all the possible numbers I am treating the differences ans an array of integers. here is the code public class Main { public static void main(String[] args) { int digit[]={3,2,5,1};// array of absolute differences int digit[]={3,2,5,1}; for(int num=1;num=9;num++) // call with all possible initial numbers findNumber(digit,4,num,0,num); } public static void findNumber(int digit[],int n,int num,int i,int oldDigit) { if(i==n) { System.out.print(num+ ); return; } { int o=digit[i]+oldDigit; if(o10) findNumber(digit,n,10*num+o,i+1,o); o=oldDigit-digit[i]; if(o0) findNumber(digit,n,10*num+o,i+1,o); } } } and here is the output 14612 14278 14276 25723 25721 25389 25387 36834 36832 36498 47945 47943 41389 41387 58612 52498 69723 69721 63167 63165 74612 74278 74276 85723 85721 85389 85387 96834 96832 96498 BUILD SUCCESSFUL (total time: 0 seconds) On Tue, Dec 13, 2011 at 11:11 PM, Dave dave_and_da...@juno.com wrote: @Amir: Presumably, since these are digits in a number, they are bounded on the bottom by 0 and on the top by radix-1. So in decimal, if a digit is 7 and the absolute difference between it and the next digit is 3, there is only one possibility for the next digit, 7-3 = 4, since 7+3 is too large. So only some subset of the 2^(n-1) combinations of addition and subtraction may be possible. Dave On Dec 13, 4:15 am, Amir hossein Shahriari amir.hossein.shahri...@gmail.com wrote: actually there are infinite number of sequences that match it for example if the absolute differences are 3 2 5 1 one possible sequence is 6 3 5 0 1 one other is 7 4 6 1 2 or 8 5 7 2 3 and you can add any integer value to all elements and the result will still be valid actually you can start with any number and and then the second number will be equal to the first number that you chose plus/minus the first absolute difference and so on so if we are given the first element of the sequence there are 2^(n-1) ways to find a valid sequence because for each absolute difference we can either add the absolute difference to the last sequence element or subtract the absolute difference from it On Mon, Dec 12, 2011 at 9:01 PM, KAY amulya.manches...@gmail.com wrote: If for a number n digits long, the absolute difference between adjacent digits is given, how to find out the number of different numbers with these absolute differences ? for eg, if n=5 and the absolute differences are 3 2 5 1 then 1 possible number is 6 3 5 0 1(because |6-3|=3,|3-5|=2 and so on...) How many such numbers will be there? -- 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
Re: [algogeeks] A binary tree question
we have to traverse in zig zaz or spirally. so we need two stack or two queus. On Mon, Dec 12, 2011 at 12:23 AM, atul anand atul.87fri...@gmail.comwrote: @Gene : if i am not wrong , level order traversal can be done using only 1 queuewhy 2 queue??? On Sun, Dec 11, 2011 at 9:53 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, Suppose we have a binary search tree as 15,12,18,17,21,11,14 then O/P will be 15 12 18 21 17 14 11. so the successor of 15 is 12 the successor of 12 is 18 and so on. I hope now its clear. Regards, Aman. On Sun, Dec 11, 2011 at 6:26 PM, WgpShashank shashank7andr...@gmail.comwrote: @atul zig-zag mean spiral traversal of tree e.g. alternate the level while traversing , if previous traversal is left to right , then next level will be right to left . @aman .quest has little ambiguity its says successor but ebvery nodes can have we can ore-order , inorder ,postorder successor isn't it ?? but i am assuming u r interesting in pre-order succesor so then 1st find the per-order successor of each node then set it , finally traverse it ? correct me if i am wrong ? Thanks Shashank Mani Computer Science BIT Mesra -- 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/-/b51VObaoMZIJ. 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. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] MYSIS AND DRISHTI-SOFT
about drishtisoft test pattern 1: technical + aptitude 2 hours abt 60 questions c 20 apti 30 and others 10 2round coding 4 to 5 questions 3 round 1 technical interview , they wiil ask u write working code , list and tree problems. On Fri, Dec 9, 2011 at 12:44 PM, aayush jain ajain...@gmail.com wrote: can anybody tell me the pattern of MYSIS AND DRISHTI-SOFT plz.. is MYSIS is vistied any NIT if yes so plz share the experienceand DRISHTI-SOFT also -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: Number Theory (Power of 3 )
u people absolutely correct that log operation take much time , i just given an approach On Sat, Dec 10, 2011 at 7:25 AM, Dave dave_and_da...@juno.com wrote: @Gaurav: Even though this is O(log n), it is bound to be slow, since it would use division and modulus are among the slowest operations on modern computers, some of which don't even have an integer division instruction. Here is a revision to my earlier code, for 32-bit integers. It should be faster since it contains no loops. bool PowerOfThree(unsigned int n) { int powsof3[32] = {1,3,0,9,27,0,81,243,0,729,0,2187,6561,0,19683,59049,0, 177147,0,531441,1594 323,0,4782969,14348907,0,43046721, 129140163,0,387420489,0,1162261467,3486784401}; int i = if( n 16 ) ? 16 : 0; if( n (i+8) ) i += 8; if( n (i+4) ) i += 4; if( n (i+2) ) i += 2; if( n = (i+1) ) i += 1; return powsof3[i] == n; } As in the previous algorithm, the first few statements use a binary search to find the bit number of the highest order bit set. There can be at most one power of three corresponding to each high-order-bit number, so we then check to see if the input number is the only possible power of three in the table of powers of 3 that is indexed by the high-order-bit number. The zeros in powsof3[] correspond to high- order-bit numbers that have no power of three. Dave On Dec 9, 2:35 am, Gaurav Kumar gkuma...@gmail.com wrote: What if we create a base 3 number from the given number N and then check if there is only 1 bit with value 1 and all values should be 0. For example, if lets say the number is 27. Its base 3 number will be 1 0 0 0, now since there is only 1 single 1 present in this representation, it is a power of 3. Gaurav On Dec 7, 2011, at 6:03 PM, saurabh singh wrote: Originaly problem rules out the use of log.Moreover log (or any floating point operations) take lot of hardware time as they are emulated on the floating point environment on most machines.Thirdly precision problem for higher values of n may cause your solution to give wron g answers,,, On Wed, Dec 7, 2011 at 11:54 PM, tech coder techcoderonw...@gmail.com wrote: what about this log(base 3 n) is of integral type then n is a power of 3 On Mon, Dec 5, 2011 at 11:36 PM, Dave dave_and_da...@juno.com wrote: @Carl: You can generate the constants the first time the procedure is called. There is no need to do them every time. So the first call would be O(wordsize) but subsequent calls are O(1). Dave On Dec 5, 10:28 am, Carl Barton odysseus.ulys...@gmail.com wrote: Sorry, I was being a bit vague. I meant what would the time complexity be then? As I understand your Constant time is Dependant on the constant pre computation you do, which is no longer the case when you generalise On 5 December 2011 16:14, Dave dave_and_da...@juno.com wrote: @Carl: Of course. For any given word size, extend the tables of powers of 2 and of 3 and change the for loop limit. Dave On Dec 5, 9:36 am, Carl Barton odysseus.ulys...@gmail.com wrote: Ah I see, in which case could you not generalise your solution for all integers? By taking into account the size of words on the computer for example? On 5 December 2011 15:09, Dave dave_and_da...@juno.com wrote: @Carl: Yes, as coded, my algorithm is for 32-bit integers. But the original poster asked for a solution using bit manipulation, and modulus and division are arithmetic operations, not bit operations. Dave On Dec 5, 8:56 am, Carl Barton odysseus.ulys...@gmail.com wrote: @Dave Yours only works for a certain subset of all possible powers or 3 doesn't it? So WgpShashank's would be more general? On 5 December 2011 14:30, Dave dave_and_da...@juno.com wrote: @WgpShashank: Yours is an O(log n) solution. Mine is O(1). Dave On Dec 5, 6:21 am, WgpShashank shashank7andr...@gmail.com wrote: @SAMMM have a look * *solution is to keep dividing the number by 3, i.e, do n = n/3 iteratively. In any iteration, if n%3 becomes non-zero and n is not 1 then n is not a power of 3, otherwise n is a power of 3 check it out ?http://codepad.org/863ptoBE Thanks Shashank Computer Science BIT Mesrahttp:// www.facebook.com/wgpshashankhttp://shashank7s.blogspot.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
Re: [algogeeks] Re: Number Theory (Power of 3 )
what about this log(base 3 n) is of integral type then n is a power of 3 On Mon, Dec 5, 2011 at 11:36 PM, Dave dave_and_da...@juno.com wrote: @Carl: You can generate the constants the first time the procedure is called. There is no need to do them every time. So the first call would be O(wordsize) but subsequent calls are O(1). Dave On Dec 5, 10:28 am, Carl Barton odysseus.ulys...@gmail.com wrote: Sorry, I was being a bit vague. I meant what would the time complexity be then? As I understand your Constant time is Dependant on the constant pre computation you do, which is no longer the case when you generalise On 5 December 2011 16:14, Dave dave_and_da...@juno.com wrote: @Carl: Of course. For any given word size, extend the tables of powers of 2 and of 3 and change the for loop limit. Dave On Dec 5, 9:36 am, Carl Barton odysseus.ulys...@gmail.com wrote: Ah I see, in which case could you not generalise your solution for all integers? By taking into account the size of words on the computer for example? On 5 December 2011 15:09, Dave dave_and_da...@juno.com wrote: @Carl: Yes, as coded, my algorithm is for 32-bit integers. But the original poster asked for a solution using bit manipulation, and modulus and division are arithmetic operations, not bit operations. Dave On Dec 5, 8:56 am, Carl Barton odysseus.ulys...@gmail.com wrote: @Dave Yours only works for a certain subset of all possible powers or 3 doesn't it? So WgpShashank's would be more general? On 5 December 2011 14:30, Dave dave_and_da...@juno.com wrote: @WgpShashank: Yours is an O(log n) solution. Mine is O(1). Dave On Dec 5, 6:21 am, WgpShashank shashank7andr...@gmail.com wrote: @SAMMM have a look * *solution is to keep dividing the number by 3, i.e, do n = n/3 iteratively. In any iteration, if n%3 becomes non-zero and n is not 1 then n is not a power of 3, otherwise n is a power of 3 check it out ?http://codepad.org/863ptoBE Thanks Shashank Computer Science BIT Mesrahttp:// www.facebook.com/wgpshashankhttp://shashank7s.blogspot.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. -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: Re : Non Decreasing Numbers
there was small mistake. correct code is int count=0; void fun(int a[],int index,int n,int i) { if(index==n) { count++; cout\n; for(int k=0;kn;k++) couta[k] ; return; } for(int j=i;j=9;j++) { a[index]=j; fun(a,index+1,n,j+1); it uses simple backtracking On Wed, Dec 7, 2011 at 1:02 PM, shady sinv...@gmail.com wrote: how to arrive at such a formulation ? can any one derive this formula ? On Mon, Sep 26, 2011 at 12:09 AM, asdqwe ayushgoel...@gmail.com wrote: that would be (n+9)C(n).. On Sep 25, 10:05 pm, shady sinv...@gmail.com wrote: @sanjay can you please tell how did you arrive at that solution ? On Sun, Sep 25, 2011 at 12:32 PM, Yogesh Yadav medu...@gmail.com wrote: +1 Gohana On Sun, Sep 25, 2011 at 12:28 PM, Sanjay Rajpal srn...@gmail.com wrote: let the number of digits be n then answer would be ((n+9)! ) / (9! * n!) Sanju :) On Sat, Sep 24, 2011 at 11:51 PM, Yogesh Yadav medu...@gmail.com wrote: mistake in last post...it was not factorialsum upto n i.e =n(n+1)/2 i.e 10! is wrong ...it will be 10(10+1)/2 On Sun, Sep 25, 2011 at 12:14 PM, Yogesh Yadav medu...@gmail.com wrote: n=1 n=2 n=3 n=4 01010!(10!)! 1 9 9! (9!)! 2 8 8! 3 7 7! 4 6 6! 5 5 5! 6 4 4! 7 3 3! 8 2 2! 9 1 1! sum 10 55220 and so on On Sun, Sep 25, 2011 at 11:46 AM, Sanjay Rajpal srn...@gmail.com wrote: Can you plz tell the answer for for 3 answer=? nd for 4 answer=? Sanju :) On Sat, Sep 24, 2011 at 10:39 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: can u plz be more..clear ..with wat the input will consist of.. wat does this mean for 2 answer=55 does that mean..that how many non decreasing digits can be formed by 2 digit num On Sun, Sep 25, 2011 at 1:08 AM, shady sinv...@gmail.com wrote: A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit. for eg. 1122, 234, 2 , 0011 is a possible 4 digit non decreasing number so given a number n, how many n digit numbers exist ? for 2 answer = 55 Can someone post complexity and their approach -- 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 -- 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
Re: [algogeeks]
loop through the elements of array. keep two vales firstlargest and 2ndlargest and update accordingly. loop i=1 to n { if(a[i]1stlargest) { 2ndlargest=1stlargest; 1stlargest=a[i]; continue; } if(A[i]2ndlargest) 2ndlargest=a[i]; }// loop closed On Mon, Nov 28, 2011 at 2:16 AM, KARTHIKEYAN V.B. kartmu...@gmail.comwrote: Hi, Find the highest and second highest element in an array in O(n) time Input : arr[]={1,4,0,7,8,9} Output : 9 and 8 Thanx in advance Regards, Karthikeyan -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: Maximize Subsquare
@ Chunyuan Ge *have u checked ur solution . ur solution is to find the submatrix all filled with 1 , but the question say that 1 can be at boundaries. * On Wed, Nov 23, 2011 at 3:00 PM, kumar raja rajkumar.cs...@gmail.comwrote: @Dark prince : what is meant by Allones(i,0.k) what subsquare he is considering here?? On 22 November 2011 23:57, DarkPrince darkprince...@gmail.com wrote: It means that the Borders of the mavximum rectangle should hav all 1s irrespective the elements inside the rectangles , it can be either 0 or 1 . -- 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.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. -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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 one
i think edit distance algorithm can not be used here because in edit distance problem we have a target string and a source string. Here we dont have any target word. I think trie can be used with some preprocessing. On Thu, Nov 24, 2011 at 11:59 PM, atul anand atul.87fri...@gmail.comwrote: http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees this would help. On Thu, Nov 24, 2011 at 9:49 PM, Vijay Meena vijay...@gmail.com wrote: Can you please elaborate... On Thu, Nov 24, 2011 at 12:14 AM, atul anand atul.87fri...@gmail.comwrote: yes levenshtein distance and BK tree can be used to solve this. where edge weight between nodes is equal to levenshtein distance. On Wed, Nov 23, 2011 at 7:14 PM, abhishek kumar afs.abhis...@gmail.comwrote: You are given a word and a dictionary. Now propose an algorithm edit the word (insert / delete characters) minimally to get a word that also exists in the dictionary. Cost of insertion and deletion is same. Write pseudocode for it. Seems like minimum edit distance problem but some modification is needed. -- Abhishek Kumar B.Tech(IT) Graduate Allahabad Contact no-+919663082731 -- 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. -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: Any one
@vikas will u please elaborate ur answer. @atul yeah thats true, target will be the words from the dictionary but we dont have a specific target, here it will be brute force if we check newly form word with each of the word in dictionary. On Sat, Nov 26, 2011 at 9:15 PM, atul anand atul.87fri...@gmail.com wrote: @vikas : to do BFS ..first you have to create tree . so what basis will you create a tree ? a dictionary can contains thousandss of word , just by taking arbitrary word from the dictionary and creating tree i guess will take lot of time. @tech coder : target will be the words from the dictionary . On Sat, Nov 26, 2011 at 6:19 PM, vikas vikas.rastogi2...@gmail.comwrote: this is well known problem, use the BFS traversal / Backtracking On Nov 26, 3:54 pm, tech coder techcoderonw...@gmail.com wrote: i think edit distance algorithm can not be used here because in edit distance problem we have a target string and a source string. Here we dont have any target word. I think trie can be used with some preprocessing. On Thu, Nov 24, 2011 at 11:59 PM, atul anand atul.87fri...@gmail.com wrote: http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees this would help. On Thu, Nov 24, 2011 at 9:49 PM, Vijay Meena vijay...@gmail.com wrote: Can you please elaborate... On Thu, Nov 24, 2011 at 12:14 AM, atul anand atul.87fri...@gmail.comwrote: yes levenshtein distance and BK tree can be used to solve this. where edge weight between nodes is equal to levenshtein distance. On Wed, Nov 23, 2011 at 7:14 PM, abhishek kumar afs.abhis...@gmail.comwrote: You are given a word and a dictionary. Now propose an algorithm edit the word (insert / delete characters) minimally to get a word that also exists in the dictionary. Cost of insertion and deletion is same. Write pseudocode for it. Seems like minimum edit distance problem but some modification is needed. -- Abhishek Kumar B.Tech(IT) Graduate Allahabad Contact no-+919663082731 -- 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. -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] cracking the coding interview book
please upload the books cracking the coding interview 5th edition and data structures and algorithms made easy, if somebody have. thanks. -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] An Array Problem
here is an O(n) approach using a stack. problem can be stated as find the 1st smaller element on the right. put the first element in stack. take next element suppose num if this number is less than elements stored in stack, pop those elements , for these pooped elements num will be the required number. put the the element (num) in stack. repeat this. at last the elements which are in next , they will have 0 (valaue) On Wed, Nov 23, 2011 at 12:02 AM, Anup Ghatage ghat...@gmail.com wrote: I can't think of a better than O(n^2) solution for this.. Any one got anything better? On Tue, Nov 22, 2011 at 8:23 PM, Ankuj Gupta ankuj2...@gmail.com wrote: Input: A unsorted array of size n. Output: An array of size n. Relationship: elements of input array and output array have 1:1 correspondence. output[i] is equal to the input[j] (ji) which is smaller than input[i] and jth is nearest to ith ( i.e. first element which is smaller). If no such element exists for Input[i] then output[i]=0. Eg. Input: 1 5 7 6 3 16 29 2 7 Output: 0 3 6 3 2 2 2 0 0 -- 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. -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: finding closest points
use a max heap of size k, On Tue, Nov 22, 2011 at 11:38 PM, Aamir Khan ak4u2...@gmail.com wrote: On Tue, Nov 22, 2011 at 8:43 PM, Dave dave_and_da...@juno.com wrote: @Ganesha: You could use a max-heap of size k in time O(n log k), which is less than O(n log n) if k O(n). We can always ensure that k = n/2. If k = n/2 then the problem can be stated as, find m points farthest from the given point by creating min-heap of size m. The elements which were present in input but not in heap will be the points nearest to the given point, where m = n-k. Dave On Nov 22, 8:56 am, ganesha suresh.iyenga...@gmail.com wrote: Given a set of points in 2D space, how to find the k closest points for a given point, in time better than nlgn. -- Aamir Khan | 3rd Year | Computer Science Engineering | IIT Roorkee -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] Time Complexity
the complexity is N^2 for each level you are traversing all the nodes below that level. for nth level , you have to traverse all n-1 nodes. so O(N^2) better to use queue , we can traverse level order in O(n). On Sat, Nov 19, 2011 at 4:58 PM, shady sinv...@gmail.com wrote: this doesn't seem like level order printing, because you are simply printing the tree starting with the children as the root node. On Sat, Nov 19, 2011 at 12:57 PM, Ankuj Gupta ankuj2...@gmail.com wrote: What is the time complexity of this code for Level Order Traversal. void printLevel(BinaryTree *p, int level) { if (!p) return; if (level == 1) { cout p-data ; } else { printLevel(p-left, level-1); printLevel(p-right, level-1); } } void printLevelOrder(BinaryTree *root) { int height = maxHeight(root); for (int level = 1; level = height; level++) { printLevel(root, level); cout endl; } } My guess is NlogN if tree is balanced if not it will be N^2. -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] Time Complexity
@ sravanreddy001 complexity is O(N^2) whether tree is balanced or not doesn't matter For each level it's visiting elements. all elements upto n-1 level . i dont know from where u got the concept of logn , the code is not making any decision to go in left or right , it is going in left and right both , so how it is nlogn. On Sun, Nov 20, 2011 at 3:12 AM, sravanreddy001 sravanreddy...@gmail.comwrote: Its NlogN if balanced.. Else N^2 For each element it's visiting at most log N elements.(assuming balanced) -- 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/-/hVQH5EtOfK4J. 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] median from continuous stream
using a max heap and min heap we can find the median On Tue, Nov 8, 2011 at 10:59 AM, Arun Vishwanathan aaron.nar...@gmail.comwrote: Hi to find running median from a stream of random generated numbers I have heard of the 2 heap ( min and max heap ) solution but I fail to understand it...could someone please explain with a small example or so ?? thanks! -- People often say that motivation doesn't last. Well, neither does bathing - that's why we recommend it daily. -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: Re : Non Decreasing Numbers
this is the solution . it also prints all the possible as well as the total count int count=0; void fun(int a[],int index,int n,int i) { if(index==n) { count++; cout\n; for(int k=0;kn;k++) couta[k] ; return; } for(int j=i;j=9;j++) { a[index]=j; fun(a,index+1,n,j); } } On Mon, Sep 26, 2011 at 12:41 AM, shady sinv...@gmail.com wrote: how ? elaborate on the solution part ? how to arrive at that formulation ? On Sep 25, 11:39 pm, asdqwe ayushgoel...@gmail.com wrote: that would be (n+9)C(n).. On Sep 25, 10:05 pm, shady sinv...@gmail.com wrote: @sanjay can you please tell how did you arrive at that solution ? On Sun, Sep 25, 2011 at 12:32 PM, Yogesh Yadav medu...@gmail.com wrote: +1 Gohana On Sun, Sep 25, 2011 at 12:28 PM, Sanjay Rajpal srn...@gmail.com wrote: let the number of digits be n then answer would be ((n+9)! ) / (9! * n!) Sanju :) On Sat, Sep 24, 2011 at 11:51 PM, Yogesh Yadav medu...@gmail.com wrote: mistake in last post...it was not factorialsum upto n i.e =n(n+1)/2 i.e 10! is wrong ...it will be 10(10+1)/2 On Sun, Sep 25, 2011 at 12:14 PM, Yogesh Yadav medu...@gmail.comwrote: n=1 n=2 n=3 n=4 01010!(10!)! 1 9 9! (9!)! 2 8 8! 3 7 7! 4 6 6! 5 5 5! 6 4 4! 7 3 3! 8 2 2! 9 1 1! sum 10 55220 and so on On Sun, Sep 25, 2011 at 11:46 AM, Sanjay Rajpal srn...@gmail.com wrote: Can you plz tell the answer for for 3 answer=? nd for 4 answer=? Sanju :) On Sat, Sep 24, 2011 at 10:39 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: can u plz be more..clear ..with wat the input will consist of.. wat does this mean for 2 answer=55 does that mean..that how many non decreasing digits can be formed by 2 digit num On Sun, Sep 25, 2011 at 1:08 AM, shady sinv...@gmail.com wrote: A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit. for eg. 1122, 234, 2 , 0011 is a possible 4 digit non decreasing number so given a number n, how many n digit numbers exist ? for 2 answer = 55 Can someone post complexity and their approach -- 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 -- 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
Re: [algogeeks] Re: matrix
people just dont read the question properly and post the answer On 9/17/11, prasanth n nprasnt...@gmail.com wrote: @sinjanspecial: i think your code is for an 1 D matrix..but i have to find for a 2D matrix.. On Sat, Sep 17, 2011 at 7:33 PM, sinjanspecial sinjanspec...@gmail.comwrote: hii I think this code will work #includestdio.h #includestring.h void largestsum(int a[],int n) { int s=0,e=0,ls=0,max=0,j,i,sum=0; for(i=0;in;i++) { sum+=a[i]; if(summax) { max=sum; e=i; s=ls; } if(sum0) { sum=0; ls=i+1; } } printf(\nlargest sum is=%d\n,max); printf(The element which make largest sum is\t); for(j=s;j=e;j++) { printf(%d\t,a[j]); } } int main() { int a[]={6,4,-5,5,2,8,-21,15,4}; int n=9; largestsum(a,n); return 0; } Thanks Regards Sinjan M.Tech(s/w engg) DTU delhi On Sep 17, 2:55 pm, prasanth n nprasnt...@gmail.com wrote: given a matrix with +ve and -ve numbers, find the submatrix with maximum sum?? -- *prasanth* -- 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. -- *prasanth* -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] Find the element in Array
@ akshat read the question properly before posting such solution On Wed, Aug 31, 2011 at 12:27 PM, Akshat Sapra sapraaks...@gmail.comwrote: Solution: arr[n],sum = 0; for ( int i = 0 ; i n; i++ ) { sum ^= arr[i]; } print sum; // required number -- 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. -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] Find the element in Array
1: use bit array(hashing) then only it is possible in O(n) On Fri, Sep 16, 2011 at 12:04 PM, tech coder techcoderonw...@gmail.comwrote: @ akshat read the question properly before posting such solution On Wed, Aug 31, 2011 at 12:27 PM, Akshat Sapra sapraaks...@gmail.comwrote: Solution: arr[n],sum = 0; for ( int i = 0 ; i n; i++ ) { sum ^= arr[i]; } print sum; // required number -- 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. -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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: no of elements of the array
+1 to don On Thu, Sep 15, 2011 at 9:40 PM, Don dondod...@gmail.com wrote: Not really. Usually you would need a second parameter indicating the size of the input. In theory it might be possible to put a marker value at the end of the array. Most implementations of malloc store the size of the memory block in the word immediately before the returned address. This is used when you free the memory. So some programmers use things like: int *data = (int *)malloc(n*sizeof(int)); And then later: int size = *(data-4)/sizeof(int); This would not work if data was declared as an array rather than as a malloced pointer. It is also completely implementation dependent, so I would not recommend it for any code which someone may someday have to maintain. Don On Sep 15, 10:59 am, rahul vatsa vatsa.ra...@gmail.com wrote: if i pass an int array to a function, is it possible to find out the no of elements in the called function ? -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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 output
+1 On Wed, Aug 31, 2011 at 9:27 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: its 4 3 i think On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d = abc\0def\0; printf(%d %d,sizeof(d),strlen(d)); getch(); } -- 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/-/nf_M_Yoep_EJ. 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. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- 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] C output
for 16 bit compiler ans is 2 3 for 32 bit compiler ans is 4 3 pls correct me if i m wrong On Wed, Sep 14, 2011 at 11:36 AM, tech coder techcoderonw...@gmail.comwrote: +1 On Wed, Aug 31, 2011 at 9:27 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: its 4 3 i think On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d = abc\0def\0; printf(%d %d,sizeof(d),strlen(d)); getch(); } -- 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/-/nf_M_Yoep_EJ. 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. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- 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] Re: Finding connection b/w 2 profiles
we can also use dfs and find if there exist path between given two nodes(profiles here). if yea , there is a connection b/w two profiles. On Wed, Sep 14, 2011 at 1:58 PM, Azhar Hussain azhar...@gmail.com wrote: Union Find Algorithm would do - Azhar. On Wed, Sep 14, 2011 at 1:42 PM, JITESH KUMAR jkhas...@gmail.com wrote: Neither depth is known nor we have to find the shortest path. We just have to find the path. -- *Regards Jitesh Kumar * -- 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] complexity of recursion
an interseting problem for a fibonacci series the recurrence relation is t(n)=t(n-1)+t(n-2)+O(1) on solving it gives upper bound of O(n^2) but when draw tree for the recurcsion we see that it is growing exponentially giving a complexity of O(2^n). so what is the complexity for fibonaacci series n^2 or 2^n -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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 output
@ prateek absolutely wrong , dear u need to brushup ur basics d is a pointer , it's can be 2 or 4 depebding on compiler On Wed, Sep 14, 2011 at 6:26 AM, PRATEEK VERMA prateek...@gmail.com wrote: 9 and 3 -- 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* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play* -- 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] Which one is better to work for ThoughtWorks or Samsung
Which one is better to work for ThoughtWorks or Samsung. ThoughtWorks package 5.86 Samsung 6.25. Those who r working in samsung or thoughtworks please reply -- 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] Max sub matrix problem
this is possible in o(n^2) with n^2 addidtional space . On Sun, Sep 11, 2011 at 11:33 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: @victor: Can u provide the algo ?? -- 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] need help
if somebody has the preparation material and videos provided by Careercup.com. Then please send me. 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.
Re: [algogeeks] Request for crack coding book ebook
please send the 5th edition if someone have thanks On Sun, Sep 4, 2011 at 11:18 PM, Sanjay Rajpal srn...@gmail.com wrote: Send it to me also. Thanx in advance .. :) Sanju :) On Sat, Sep 3, 2011 at 9:58 AM, UMESH KUMAR kumar.umesh...@gmail.comwrote: hi anybody do you have CrackCoding ebook pls send . 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.
Re: [algogeeks] Re: How
++rahul see a constructor cant recieve an srgument of the same class type(by value), although it can recieve a reference of same class type, because the process become recursiv eand go infinite till stack overflow On Tue, Aug 30, 2011 at 9:28 AM, rahul sharma rahul23111...@gmail.comwrote: a. default constructor c. copy d. parametrized. in b it should recieve reference On Aug 30, 9:24 pm, Anuj kumar anonymize...@gmail.com wrote: Q)Given a class named Book, which of the following is not a valid constructor? (A) Book ( ) { } (B) Book ( Book b) { } (C) Book ( Book b) { } (D) Book (char* author, char* title) { } Ans:B how plz give reason.. -- 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] affect of change
c and d will be affected. On Tue, Aug 30, 2011 at 8:51 AM, nidhi jain nidhi.jain311...@gmail.comwrote: yes, D vl give an error ,as increment operator cannot be used as lvalue for assignment. NIDHI JAIN INFORMATION TECHNOLOGY(FINAL YEAR) 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. -- 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] max sum in submatrix
can u elaborate On Tue, Aug 30, 2011 at 11:13 AM, sukran dhawan sukrandha...@gmail.comwrote: kadane 's algo ? On Tue, Aug 30, 2011 at 1:19 AM, tech coder techcoderonw...@gmail.comwrote: 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. -- 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
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] 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] 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 !!
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] 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: 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.
Re: [algogeeks] Adding Two no without using any operator...??
int add(int a,int b) { int sum=a^b; int carry=ab; while(carry!=0) { carry=1; a=sum; b=carry; sum=a^b; carry=ab; } return sum; } On Sat, Aug 27, 2011 at 12:28 PM, Mohit kumar lal kumarmohit...@gmail.comwrote: int add(int a, int b) { if (!a) return b; else return add((a b) 1, a ^ b); } On Sun, Aug 28, 2011 at 12:54 AM, sagar pareek sagarpar...@gmail.comwrote: yeah one option is half adder with xor and and operators one more solution http://www.ideone.com/B07bn On Sun, Aug 28, 2011 at 12:41 AM, Gaurav Menghani gaurav.mengh...@gmail.com wrote: I guess you mean without using any 'arithmetic operator'. If yes, it can be done with XOR and AND operators. Not sure how it can be done otherwise, without using any kind of operators AT ALL. On Sun, Aug 28, 2011 at 12:37 AM, 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 view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/MpNKzlE3UuwJ. 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. -- Gaurav Menghani -- 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. -- Mohit kumar lal rit2009014 IIIT ALLAHABAD contact@9454681805 kumarmohit...@gmail.com mohitkumar...@yahoo.com rit2009...@iiita.ac.in http://profile.iiita.ac.in/rit2009014 -- 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: matrix finding immediate neighour
@ shashank and all can we an approach that take less time than O(N^2). I mean not in O(N ) or nlogn but n^2 some optimiation On Thu, Aug 25, 2011 at 8:43 PM, WgpShashan) k shashank7andr...@gmail.com wrote: @Sharvan ..Yes We Can do That and yes i forgot that intead of locals.add(a[i][j]) , we need tow write locals.add(i+j) Hope its fine now :) *Thanks Shashank Mani Computer Science Birla Institute of Technology Mesra* -- 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/-/FKYupw3YSG4J. 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] chanege in immutable string
in java a tring object is immutable but in following code String s=java; s+=c c++; System.out.print(s); the output is javac c++ why this is so -- 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] chanege in immutable string
thanks to all got it On Fri, Aug 26, 2011 at 4:54 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: @tech coder: When u execute : s+=c c++; a new string object is created with the value of s appended with c c++. Now s is made to hold the reference of this new string object. Thus the older string object is not modified, but a new string string object is created. -- 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] unsorted array problem
it can be done in O(N) by using XOR ing the elements 1: Xor all the elemnts since those elemnts that even freq will nullify each other we get number taht will tell in which the two required number differ. 2: divide the array in two sets on the basis of bit in which numbers differ 3:1 element will be in one set another will be in another set 4: XOR both the sets again we get both the elemts On Thu, Aug 25, 2011 at 12:50 PM, Umesh Jayas algowithum...@gmail.comwrote: int main() { int arr[]={1,2,5,1,5,1,1,3,2,2,}; int elements = sizeof(arr)/sizeof(arr[0]); int count=1; int num; sort(arr,arr+elements); num=arr[0]; for(int i=1;ielements;i++) { if(arr[i]==num) count++; else { if(count%2==0) { num=arr[i]; count=1;} else {cout\narr[i-1]; count=1; num=arr[i]; } } } getch(); } complexity: O(nlogn) -- 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: unsorted array problem
@Tech: I'm not sure I understand your algorithm. Let's try it on {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of times are 3 and 4. We xor the numbers getting 7 = 111 in binary. Now how do we divide the numbers into two groups? see we come to know that both number differ at bit1 bit2 and bit3 we need only bit1 set1 contain the numbers whose bit1 is set including 3 set2 contain the numbers whose bit1 is clear including 4 now xoring 1st set we get 3 xor ing 2nd set we get 4 (bacuase all others appear even no of time they will nullify each other) -- 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: unsorted array problem
@ Don exactly waht u write i wanted to say On Fri, Aug 26, 2011 at 11:52 AM, tech coder techcoderonw...@gmail.comwrote: @Tech: I'm not sure I understand your algorithm. Let's try it on {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of times are 3 and 4. We xor the numbers getting 7 = 111 in binary. Now how do we divide the numbers into two groups? see we come to know that both number differ at bit1 bit2 and bit3 we need only bit1 set1 contain the numbers whose bit1 is set including 3 set2 contain the numbers whose bit1 is clear including 4 now xoring 1st set we get 3 xor ing 2nd set we get 4 (bacuase all others appear even no of time they will nullify each other) -- 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] matrix finding immediate neighour
write a code which will receive as input a matrix (int[][] matrix) and which should find all local maximum from the matrix. A local maximum is such a number in the matrix that is greater than all its immediate neighbors. The method should return the List of locations of all local maximum numbers found. -- 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] tech coder wants to chat
--- tech coder wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-1d33702e37-993bf651e4-cs5cZharYeuSTf7aKwuqhWm2blM You'll need to click this link to be able to chat with tech coder. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with tech coder, visit: http://mail.google.com/mail/a-1d33702e37-993bf651e4-cs5cZharYeuSTf7aKwuqhWm2blM Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- 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] finding string in matrix grid
check whether a string is present in matrix grid (either horizonatal(left to right), vertical(top to boottom) ,reverse horizonatal(right to left) reverse vertical(bottom to top). i think the question is clear. first try to give solution for horizontal and vertical only, just give the 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.