Re: [algogeeks] Re: Finding non-repetitive element from an Array with complexity n
to get the non repeating element we have to travese array atleast once.so Time complixity has to minimum o(n).as I suppose.. The XOr solution will fail because odd number will be there... Hashing itself require o(n) space in worst case. On Mon, Apr 18, 2011 at 12:40 AM, sravanreddy001 sravanreddy...@gmail.comwrote: can u explain ur solution with one of these sets? {1,2,1,3,2,1} {1,2,1,3,2,2} an element can repeat for any number of times = 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.
Re: [algogeeks] Re: Lets C Who Really Loves Perfect Square .................
@dave..Can you please explain your logic .. Regards, Ashish On Thu, Feb 24, 2011 at 6:32 AM, Dave dave_and_da...@juno.com wrote: Try this: int i,k,n; long long j,nsq; for( n = 31623 ; n 10 ; ++n ) { nsq = (long long)n * (long long)n; j = nsq; k = 0; for( i = 0 ; i 10; ++i ) { k |= (1 (j % 10)); j /= 10; } if( k == 01777 ) printf(%i %lli\n,n,nsq); } It finds 76 answers in the blink of an eye, the first being 32043^2 and the last being 99066^2. Dave On Feb 22, 3:17 pm, bittu shashank7andr...@gmail.com wrote: How to find a number of 10 digits (non repeated digits) which is a perfect square? perfect square examples: 9 (3x3) 16 (4x4) 25(5x) etc. Ten digit number example 1,234,567,890 Thanks Regards Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Pairwise Sum Array
I think.. As like no are a,b,c,d,e so sum will be a+b,a+c,a+d,a+e,b+c,b+d,b+e,c+d,c+e,d+e; so maximuum value will be d+e which is last element of array given take last three value 1.c+d 2.c+e 3.d+e eq(1)-eq(2)=d-e; solving it with 3rd eq will give d and e and with these value we can get other values On Thu, Feb 24, 2011 at 2:52 AM, radha krishnan radhakrishnance...@gmail.com wrote: This s a topcoder problem :) On Wed, Feb 23, 2011 at 7:16 PM, bittu shashank7andr...@gmail.com wrote: If pairwise sums of 'n' numbers are given in non-decreasing order identify the individual numbers. If the sum is corrupted print -1 Example: i/p: 4 5 7 10 12 13 o/p: 1 3 4 9 Thanks Regards Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Pairwise Sum Array
There must be another good solution..please let me know . Thanks On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: I think.. As like no are a,b,c,d,e so sum will be a+b,a+c,a+d,a+e,b+c,b+d,b+e,c+d,c+e,d+e; so maximuum value will be d+e which is last element of array given take last three value 1.c+d 2.c+e 3.d+e eq(1)-eq(2)=d-e; solving it with 3rd eq will give d and e and with these value we can get other values On Thu, Feb 24, 2011 at 2:52 AM, radha krishnan radhakrishnance...@gmail.com wrote: This s a topcoder problem :) On Wed, Feb 23, 2011 at 7:16 PM, bittu shashank7andr...@gmail.com wrote: If pairwise sums of 'n' numbers are given in non-decreasing order identify the individual numbers. If the sum is corrupted print -1 Example: i/p: 4 5 7 10 12 13 o/p: 1 3 4 9 Thanks Regards Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
The basic solution which is coming to the mind is to covert string first palindrome and apply livishthein distance to both string(original one and changed string) to check how many substiutions you require for the palindrome. On Wed, Feb 23, 2011 at 9:11 PM, radha krishnan radhakrishnance...@gmail.com wrote: Dynamic Programming :P On Wed, Feb 23, 2011 at 7:19 PM, Balaji S balaji.ceg...@gmail.com wrote: can anyone help?? how to convert a string into a palindrome..with MINIMUM NUMBER OF SUBSTITUTIONS ( operations..) -- balaji ;-) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Large File Millions of Records
take an array of 10 ,travese the whole rcord and apply min heap on these 10 elements. as like first 10 no will be there and we apply minheap so we will get minimun num in these 10 number..If next numbe is greater then minimun no in array ..we will replace it and apply minheap ... On Thu, Feb 17, 2011 at 11:12 AM, Jammy xujiayiy...@gmail.com wrote: Divide records into parts that could fit into main memory. Do rank find algorithm for certain range if necessary. On Feb 16, 7:26 pm, bittu shashank7andr...@gmail.com wrote: given a very large file (millions of record), find the 10 largest numbers from it.in minimum time complexity Don't think about hashing . Again Its Flat File Not the Database Thanks Regards Shashank Mani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: String Operation
trie tree will be better to implement On Thu, Feb 17, 2011 at 11:07 AM, Jammy xujiayiy...@gmail.com wrote: Greedy, always choose the remaining one that is the lexicographically smallest since choose any other way will yield a lexicographically greater one. void concante(char **strings, int n){ qsort(strings,n,sizeof(char *),compareStr); } int compareStr(const void *a, const void *b){ return strcmp(*(char **)a,*(char **)b); } On Feb 16, 10:05 pm, simplyamey kulkarniamey2...@gmail.com wrote: Try this code. #includeiostream #includestring using namespace std; int main() { string sArray[5] ={aab,abc,bba,acc,bcc}; int n = 5; for(int i = 0;i n; i++) { for( int j = 0; j n - 1 ; j++) { if(sArray[j] sArray[j+1]) { string temp = sArray[j]; sArray[j] = sArray[j + 1]; sArray[j+1]= temp; } } } string sTemp; for(int k = 0; k n ;k++) { sTemp = sTemp + sArray[k];} coutprinting result:: sTempendl; } n = Number of strings. On Feb 17, 9:56 am, bittu shashank7andr...@gmail.com wrote: Given a group of strings, find a string by concatenating all the strings in any order which produces the lexicographically smallest string. For e.g strings are acc bcc abb So the string formed should be abbaccbcc Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Tree problem(Amazon)
jalaj back to algogeeks.. On Mon, Feb 7, 2011 at 6:09 PM, rahul rai raikra...@gmail.com wrote: Are all the integers positive only ? On 2/7/11, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: you are given a bst where each node has a int value , parent pointer , and left and right pointers , write a function to find a path with a given sum value. Path can go from left subtree tree , include root and go to right tree as well . we need to find these paths also . 5 / \ 110 / \/ \ 0 2 6 11 so to find 16 we say it is 1 to 5 to 10 10 to 6 try make use of parent pointer and find a solution :-o -- With Regards, *Jalaj Jaiswal* (+919019947895) Final Year Undergraduate, IIIT 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. -- Rahul K Rai rahulpossi...@gmail.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] [Athena 2011]
didn't get your question dude On Wed, Jan 12, 2011 at 10:39 PM, Pratik Bhadkoliya pkbhadkol...@gmail.comwrote: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) is an ordered list of positive integers Let magic(value) denote the number of such ordered lists that exist such that gcd(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)=1 AND max(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)=value Find the divisors of 11(18 -digits) . For each of the divisors D , compute magic(D) . Find the last 8 digits of the sum of all the magic(D) computed . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] 10 most repeating words
use a array of 10 and apply min heap On Thu, Oct 21, 2010 at 7:05 PM, Vinay... vinumars...@gmail.com wrote: how do u find 10 most repeating words on a large file containing words in most efficient way...if it can also be done using heapsort plz post ur answers.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: 2 elements with sum = x
take two pointer p and q p=a[0] and q=a[n-1]; sum=p+q; if(sumx) q--; if (sumx) p++; On Sun, Oct 10, 2010 at 6:54 PM, Rohit email.rohit.n...@gmail.com wrote: On Oct 10, 10:48 am, Shravan shravann1...@gmail.com wrote: http://ideone.com/D5W2y Good :). What if array is unsorted. What will be the best solution in terms of time complexity? Better then (nlog(n)+n). Regards Rohit -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: Largest Rectangle in a binary Matrix:
This question was asked in google interview one solution for this question is DP make a matrix p (all rows and columns are initialized to zero) if(a[i][j]==1]{ p[i][j]=min(p[i-1][j],p[i,j-1],p[i-1][j-1]]+1; } else p[i][j]=0; f find p[i][j] such that its has max value. On Sun, Oct 10, 2010 at 7:13 PM, Chi c...@linuxdna.com wrote: Nevermind. I don't think Z-curve is a good solution for this problem. This question was asked before, and somebody wrote a much simplier solution. I wanted to show you only the quadtree or spatialindex. If you have a quadtree-Key like this: 123123121212 You can make a query like this: if ( $key = substr (0, 6, 123123121212 ) then ... this will query all subsquares from index 123123x. It is used by Google Maps and Microsoft Maps. The problem with the quadtree is that overlapping square, or rectangle would not be found. From Wikipedia: The resulting ordering can equivalently be described as the order one would get from a depth-first traversal of a quadtree; because of its close connection with quadtrees, the Z-ordering can be used to efficiently construct quadtrees and related higher dimensional data structures http://en.wikipedia.org/wiki/Z-order_%28curve%29 http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves On Oct 10, 2:04 pm, Harshal hc4...@gmail.com wrote: @Chi pls provide a link to learn z-curve implementation in such problems -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: Largest Rectangle in a binary Matrix:
ohh..I think my solution will work on square not on rectangles. On Sun, Oct 10, 2010 at 8:13 PM, Mridul Malpani malpanimri...@gmail.comwrote: @ ashish agarwal ur solution will not work on this : 10101 0 1 11000 On Oct 10, 6:59 pm, ashish agarwal ashish.cooldude...@gmail.com wrote: This question was asked in google interview one solution for this question is DP make a matrix p (all rows and columns are initialized to zero) if(a[i][j]==1]{ p[i][j]=min(p[i-1][j],p[i,j-1],p[i-1][j-1]]+1;} else p[i][j]=0; f find p[i][j] such that its has max value. On Sun, Oct 10, 2010 at 7:13 PM, Chi c...@linuxdna.com wrote: Nevermind. I don't think Z-curve is a good solution for this problem. This question was asked before, and somebody wrote a much simplier solution. I wanted to show you only the quadtree or spatialindex. If you have a quadtree-Key like this: 123123121212 You can make a query like this: if ( $key = substr (0, 6, 123123121212 ) then ... this will query all subsquares from index 123123x. It is used by Google Maps and Microsoft Maps. The problem with the quadtree is that overlapping square, or rectangle would not be found. From Wikipedia: The resulting ordering can equivalently be described as the order one would get from a depth-first traversal of a quadtree; because of its close connection with quadtrees, the Z-ordering can be used to efficiently construct quadtrees and related higher dimensional data structures http://en.wikipedia.org/wiki/Z-order_%28curve%29 http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-. .. On Oct 10, 2:04 pm, Harshal hc4...@gmail.com wrote: @Chi pls provide a link to learn z-curve implementation in such problems -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.comalgogeeks%252bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Yahoo Question:Greatest Sub-sequential sum
@ashita I think its working fine for this seq also i=1 and j=5 and sum =25 {3,4,17,-8,9} correct me On Sat, Sep 11, 2010 at 2:16 AM, ashita dadlani ash@gmail.com wrote: http://codepad.org/Jui20xme http://codepad.org/Jui20xmea little modification over anand's code. On Sat, Sep 11, 2010 at 2:33 PM, ashita dadlani ash@gmail.com wrote: @anand: the maximum sum obtained from your solution is correct. However,the subarray printed is not correct for the following case: {-2,3,4,17,-8} -8 is also getting printed which is not a part of thw subsequence. On Sat, Sep 11, 2010 at 2:00 PM, ashita dadlani ash@gmail.comwrote: @ashish: what if the array is {-2,3,4,17,-8,9}? On Wed, Sep 8, 2010 at 8:52 AM, Anand anandut2...@gmail.com wrote: Maximum Value Contiguous Subsequence problem in O(n). http://codepad.org/BhYxSlp4 On Tue, Sep 7, 2010 at 2:40 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: yeah..it will be i=j+1; it was misprinted On Tue, Sep 7, 2010 at 10:57 AM, Sahana Gururaj sahan...@gmail.comwrote: In the else if condition, the increment of the end index i should be i=j+1, not i=j+i; Otherwise the algo is right, follows the principles of Kadane's algo : http://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm On Mon, Sep 6, 2010 at 3:50 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: int max=0,sum=0,begin=0,end=0,i=0; for(int j=0 to n){ sum+=a[j]; if(maxsum){ max=sum; begin=i; end=j; } else if(sum0){ i=j+i; sum=0; } return sum; i will tell the starting index and j will tell ending index; o(n); correct me if i am wrong On Mon, Sep 6, 2010 at 1:42 PM, bittu shashank7andr...@gmail.comwrote: Given a sequence of integers, find a continuous subsequence which maximizes the sum of its elements, that is, the elements of no other single subsequence add up to a value larger than this one. An empty subsequence is considered to have the sum 0; thus if all elements are negative, the result must be the empty sequence. Solution:O(n^2) i want O(nlogn)...??? #include stdio.h #includeconio.h #includeiostream.h #includestdlib.h int main() { int a[] = {-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1}; int length = 11; int begin, end, beginmax, endmax, maxsum, sum, i; sum = 0; beginmax = 0; endmax = -1; maxsum = 0; for (begin=0; beginlength; begin++) { sum = 0; for(end=begin; endlength; end++) { sum += a[end]; if(sum maxsum) { maxsum = sum; beginmax = begin; endmax = end; } } coutsum\t; } coutendl; for(i=beginmax; i=endmax; i++) { printf(%d\n, a[i]); } getch(); } its has time complexity O(n^2) ..does better solution exist -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sahana Gururaj -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http
[algogeeks] LIS in nlogn
Can anybody tell me least increasing sub sequence in nlogn please try to provide code in C -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] LIS in nlogn
can you give link for this On Sat, Sep 11, 2010 at 6:10 AM, Nikhil Agarwal nikhil.bhoja...@gmail.comwrote: This has been discussed already.Please refer that post I have provided the actual code . On Sat, Sep 11, 2010 at 3:20 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: Can anybody tell me least increasing sub sequence in nlogn please try to provide code in C -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards Nikhil Agarwal Senior Undergraduate Computer Science Engineering, National Institute Of Technology, Durgapur,India http://tech-nikk.blogspot.com http://beta.freshersworld.com/communities/nitd -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Excellent Compilation of Interview Questions
aham aham On Fri, Sep 10, 2010 at 12:56 PM, Shashank Krishna sasan...@gmail.comwrote: Excellent Compilation of Interview Questions Visit http://www.cracktheinterview.org/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Yahoo Question:Greatest Sub-sequential sum
yeah..it will be i=j+1; it was misprinted On Tue, Sep 7, 2010 at 10:57 AM, Sahana Gururaj sahan...@gmail.com wrote: In the else if condition, the increment of the end index i should be i=j+1, not i=j+i; Otherwise the algo is right, follows the principles of Kadane's algo : http://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm On Mon, Sep 6, 2010 at 3:50 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: int max=0,sum=0,begin=0,end=0,i=0; for(int j=0 to n){ sum+=a[j]; if(maxsum){ max=sum; begin=i; end=j; } else if(sum0){ i=j+i; sum=0; } return sum; i will tell the starting index and j will tell ending index; o(n); correct me if i am wrong On Mon, Sep 6, 2010 at 1:42 PM, bittu shashank7andr...@gmail.com wrote: Given a sequence of integers, find a continuous subsequence which maximizes the sum of its elements, that is, the elements of no other single subsequence add up to a value larger than this one. An empty subsequence is considered to have the sum 0; thus if all elements are negative, the result must be the empty sequence. Solution:O(n^2) i want O(nlogn)...??? #include stdio.h #includeconio.h #includeiostream.h #includestdlib.h int main() { int a[] = {-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1}; int length = 11; int begin, end, beginmax, endmax, maxsum, sum, i; sum = 0; beginmax = 0; endmax = -1; maxsum = 0; for (begin=0; beginlength; begin++) { sum = 0; for(end=begin; endlength; end++) { sum += a[end]; if(sum maxsum) { maxsum = sum; beginmax = begin; endmax = end; } } coutsum\t; } coutendl; for(i=beginmax; i=endmax; i++) { printf(%d\n, a[i]); } getch(); } its has time complexity O(n^2) ..does better solution exist -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sahana Gururaj -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Yahoo Question:Greatest Sub-sequential sum
int max=0,sum=0,begin=0,end=0,i=0; for(int j=0 to n){ sum+=a[j]; if(maxsum){ max=sum; begin=i; end=j; } else if(sum0){ i=j+i; sum=0; } return sum; i will tell the starting index and j will tell ending index; o(n); correct me if i am wrong On Mon, Sep 6, 2010 at 1:42 PM, bittu shashank7andr...@gmail.com wrote: Given a sequence of integers, find a continuous subsequence which maximizes the sum of its elements, that is, the elements of no other single subsequence add up to a value larger than this one. An empty subsequence is considered to have the sum 0; thus if all elements are negative, the result must be the empty sequence. Solution:O(n^2) i want O(nlogn)...??? #include stdio.h #includeconio.h #includeiostream.h #includestdlib.h int main() { int a[] = {-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1}; int length = 11; int begin, end, beginmax, endmax, maxsum, sum, i; sum = 0; beginmax = 0; endmax = -1; maxsum = 0; for (begin=0; beginlength; begin++) { sum = 0; for(end=begin; endlength; end++) { sum += a[end]; if(sum maxsum) { maxsum = sum; beginmax = begin; endmax = end; } } coutsum\t; } coutendl; for(i=beginmax; i=endmax; i++) { printf(%d\n, a[i]); } getch(); } its has time complexity O(n^2) ..does better solution exist -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] fork() problem
I think 4. On Sat, Sep 4, 2010 at 9:03 AM, Maria lydwin.ma...@gmail.com wrote: How many processes are created in this snippet? Main() { Fork(); Fork() fork () || fork (); Fork (); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: find duplicate and missing element
In this method overflow will be there..if number is just bigger...so by doing XOR we can get missing number and repeated number . take xor of all element of array and take this xor with array[1...n] So we get xor of two numbers. now get set bit of this xor and proceed. On Thu, Sep 2, 2010 at 12:36 AM, bittu shashank7andr...@gmail.com wrote: @luckyzoner can post the c program of what u ave said above.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: Take 5 digit number and find 2 power that number.............
I think it will be 1x On Wed, Sep 1, 2010 at 10:53 PM, Yan Wang wangyanadam1...@gmail.com wrote: Maybe you misunderstand the question. The question is how to compute 2^X where 0 = X = 9? How? On Wed, Sep 1, 2010 at 10:48 PM, Ruturaj rutura...@gmail.com wrote: a 5 digit number is of order 10^5 which is 10^16 of which int in C is of size. Just multiply both numbers. On Sep 2, 10:39 am, prasad rao prasadg...@gmail.com wrote: Program that takes a 5 digit number and calculates 2 power that number and prints it and should not use the Big-integer and Exponential Function's. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: Google Interview Question
but addition also should be in array On Sun, Aug 22, 2010 at 3:05 AM, arpit agarwal erarpitagar...@gmail.comwrote: Just find out the max and 2nd max in n + log(n) -2 steps and add them. there is no need for sorting as such -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] How to find two missing numbers from an unsorted continuous natural numbers array [only use O(1) space and O(n) time]
take the sum of array and product. if they were present then sum will be n(n-1)/2 and product will be n!. make two eq of a+b and a-b with these values and get the num On Thu, Aug 12, 2010 at 5:26 AM, vijay auvija...@gmail.com wrote: How to find two missing numbers from an unsorted continuous natural numbers array [only use O(1) space and O(n) time] -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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 of two arrays..
a[1n] b[1...m] find median of two array say n1 and m1..if n1m1 then median of both array can't be in in region a[n1..n] and b[1...m1]so now search space is reduced ..and we continue like this untill we find median. On Thu, Aug 5, 2010 at 6:37 AM, AlgoBoy manjunath.n...@gmail.com wrote: find the median of two sorted arrays..which have unequal lengths... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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 duplicate
travse array and check that if(a[i]==a[i+1]||a[i]==a[i+2]); if more then n/2 no are there then that condition will satisfy ...adjust with boundary condition On Thu, Aug 5, 2010 at 6:36 AM, AlgoBoy manjunath.n...@gmail.com wrote: an array in which n/2 elements are unique...and the remaning n/2 have the same elements but reapeated n/2 times. can anyone suggest a linear solution with constant space/... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Amazon Placement Question
I think use bfs ... On Thu, Jul 29, 2010 at 11:26 AM, irfan naseef irfannase...@gmail.comwrote: On Thu, Jul 29, 2010 at 11:35 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: please explain q ..i didnt understand On Thu, Jul 29, 2010 at 11:01 AM, irfan irfannase...@gmail.com wrote: I attended Amazon placement test today . There was a question where i got confused.It is as follows. Give an algorithm to connect all nodes in one level of a binary tree . 5 5 / \ / \ 8 2 8 2 / \ / / \ / 1 2 61 --- 2 --6 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Sorry for that. I attached a jpg file showing what shud the algo do . Question is that, we are given a tree. algo shud connect all the nodes which are in same level. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] algorithm to draw a line
draw a line or equation of a line? On Mon, Jul 12, 2010 at 4:38 PM, Anand anandut2...@gmail.com wrote: 2 coordinate points p(x,y)and q(x,y) are given and write an algorithm to draw aline -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] graph
@anand ..can you explain it more with example On Mon, Jul 12, 2010 at 10:19 AM, Anand anandut2...@gmail.com wrote: topological sort would cover every vertex once. The path given by Topological sort would be the answer. We can also calculate the vertices given by topological sort and compare it with given vertices. if it is same then graph G does contain a directed path that touches every vertex exactly once. On Mon, Jul 12, 2010 at 10:08 AM, Love-143 lovekesh6mn...@gmail.comwrote: Give a linear-time algorithm for the following task. Input: : A directed acyclic graph G (V,E) Question: Does G contain a directed path that touches every vertex exactly once? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Phone Numbers Yet Again!!!
@amit..can you little explain this On Mon, Jul 12, 2010 at 4:50 PM, Amir hossein Shahriari amir.hossein.shahri...@gmail.com wrote: this can be done in O(n) using DP: for (i=n-1;i=0;i--){ dp[i]=max(dp[i+2],dp[i+3]); // usual if (a[i]==a[i+1]) // excellent size 2 dp[i]=max(dp[i],2+dp[i+2]); if (a[i]==a[i+1] a[i+1]==a[i+2])//excellent size 3 dp[i]=max(dp[i],2+dp[i+3]); if (a[i]==a[i+1] || a[i]==a[i+2] || a[i+1]==a[i+2]) // good dp[i]=max(dp[i],1+dp[i+3]); } the result is in dp[0] -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] solutions?
solution for topcoder all available but not others On Sun, Jul 11, 2010 at 2:19 AM, venkat kumar svenkatkuma...@gmail.comwrote: are solutions available for problems in spoj,uva,codedhef,topcoder,etc.etc.?pls tell me tnkyou -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Sort
for sort you have to traverse array atleast once ..and after it some sorting procedure will come. On Fri, Jul 9, 2010 at 12:55 PM, Devendra Pratap Singh dpsingh.ii...@gmail.com wrote: plz write a code to Sort n integer in the range 1 to n^2 in O(n) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Yahoo
it will be 1:1 because probability of guy is 1/2+1/2*1/2+1/2*1/2*1/2.=1 and girls and boys has same probability On Sun, Jul 4, 2010 at 6:00 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: yeah 1:1 On Sun, Jul 4, 2010 at 4:57 PM, Amit Jaspal amitjaspal...@gmail.comwrote: it will be 1:1 On Sun, Jul 4, 2010 at 4:50 PM, Jitendra Kushwaha jitendra.th...@gmail.com wrote: it will be half... On Sun, Jul 4, 2010 at 4:18 PM, Piyush Verma 114piy...@gmail.comwrote: In a village in each family they give birth to children till they get a boy. IF girl child they try again. What is the ratio of boys to girls. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] amazon question
We can do 4 type of treversal. If we do inorder then we will get sorted array .If we do an inorder traversal then we would get a sorted list which if we convert into a BST would again become a list and we would loose out on the original structure of the tree. and same will be happen with post order now remaining preorder and level order. when we do level order traversal it will require more space as it uses BFS approach .So to do in o(logn) we do preorder travesal. On Sat, Jul 3, 2010 at 5:46 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: serialize... is it level order traversal ??? give an example...? On Sat, Jul 3, 2010 at 12:36 PM, divya sweetdivya@gmail.com wrote: Design an algorithm and write code to serialize a binary tree. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.