Re: [algogeeks] Adobe question
It is worse than the knapsack problem because not only does the size of each item matter, but its placement on the sheet matters. I don't think that there is a practical solution which is always optimal. You can get a pretty good solution by placing as many letters as possible on the page in rows and columns, and then repeatedly sliding all of the letters as far as possible in one direction (a different direction each time) to open up space to fit more letters. Keep doing that until it doesn't work any more. If you get an arrangement which holds N letters, you could save it and try for N+1 using only the N+1 smallest letters. Don On Tuesday, June 25, 2013 7:14:53 AM UTC-4, jagannath wrote: Is this not similar to knapsack problem? On Fri, Jun 21, 2013 at 11:24 AM, Ravi Ranjan ravi.c...@gmail.comjavascript: wrote: There is a Blank Paper Sheet, Given a list of characters and their sizes, for ex. A, P, O, N, Q with different font sizes and designs. Now we need to cut characters from given sheet of paper of all sizes atleast once. And also try to maxmize number of characters cut. Along with this, when you remove a character, rest paper is more or less like a rough sheet left. So we should try to minimize that rough sheet size as well. Write Algo for this. Provide Data Structure, Complexity of algorithm. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+...@googlegroups.com javascript:. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] Adobe question
Is this not similar to knapsack problem? On Fri, Jun 21, 2013 at 11:24 AM, Ravi Ranjan ravi.cool2...@gmail.comwrote: There is a Blank Paper Sheet, Given a list of characters and their sizes, for ex. A, P, O, N, Q with different font sizes and designs. Now we need to cut characters from given sheet of paper of all sizes atleast once. And also try to maxmize number of characters cut. Along with this, when you remove a character, rest paper is more or less like a rough sheet left. So we should try to minimize that rough sheet size as well. Write Algo for this. Provide Data Structure, Complexity of algorithm. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
[algogeeks] Adobe question
There is a Blank Paper Sheet, Given a list of characters and their sizes, for ex. A, P, O, N, Q with different font sizes and designs. Now we need to cut characters from given sheet of paper of all sizes atleast once. And also try to maxmize number of characters cut. Along with this, when you remove a character, rest paper is more or less like a rough sheet left. So we should try to minimize that rough sheet size as well. Write Algo for this. Provide Data Structure, Complexity of algorithm. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] adobe question help
N = (N | ((1(j-i+1)-1)i) (Mi); On 12 October 2011 01:22, prasad jondhale jondhale.pra...@gmail.com wrote: grt -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Bittu Sarkar 5th Year Dual Degree Student Department of Computer Science Engineering Indian Institute of Technology Kharagpur -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] adobe question help
N=(N( (~0j) | (~(1i))) | (Mi) With regards, Praveen Raj DCE-IT 735993 praveen0...@gmail.com On Tue, Oct 25, 2011 at 11:46 AM, Bittu Sarkar bittu...@gmail.com wrote: N = (N | ((1(j-i+1)-1)i) (Mi); On 12 October 2011 01:22, prasad jondhale jondhale.pra...@gmail.comwrote: grt -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Bittu Sarkar 5th Year Dual Degree Student Department of Computer Science Engineering Indian Institute of Technology Kharagpur -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] adobe question help
This is a question from Laakman. This code operates by clearing all bits in N between position i and j, and then ORing to put M in there 1 public static int updateBits(int n, int m, int i, int j) { 2 int max = ~0; /* All 1's */ 3 4 // 1's through position j, then 0's 5 int left = max - ((1 j) - 1); 6 7 // 1's after position i 8int right = ((1 i) - 1); 9 10 // 1's, with 0s between i and j 11 int mask = left | right; 12 13 // Clear i through j, then put m in there 14 return (n mask) | (m i); 15 } Gaurav On Oct 1, 2011, at 4:26 AM, rahul sharma rahul23111...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 _ #includestdio.h #includestdlib.h int main() { int N,M,i,j; printf(Enter value of N \n); scanf(%d,N); fflush(stdin); printf(Enter value of M \n); scanf(%d,M); fflush(stdin); printf(Enter value of i \n); scanf(%d,i); fflush(stdin); printf(Enter value of j \n); scanf(%d,j); fflush(stdin); int a=0,k; for( k=0;kj;k++) { a= a1; a=a|1; } for(k =0;ki;k++) { a=a1; } N = N (~a); printf(value of N is %d,N); for(k=0;ki;k++) M=M1; N=N|M; printf(value of N is %d,N); getchar(); } isnt it give us wrong mask say i=2; j=6; it gives mask as(i.e ~a) 0011 but i think from 2 to 6 5 0's are neededplz tell the above prog is ok???or not???check by giving any input whose 7thy bit is set...thnx in advance -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] adobe question help
grt -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] adobe question help
You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 _ #includestdio.h #includestdlib.h int main() { int N,M,i,j; printf(Enter value of N \n); scanf(%d,N); fflush(stdin); printf(Enter value of M \n); scanf(%d,M); fflush(stdin); printf(Enter value of i \n); scanf(%d,i); fflush(stdin); printf(Enter value of j \n); scanf(%d,j); fflush(stdin); int a=0,k; for( k=0;kj;k++) { a= a1; a=a|1; } for(k =0;ki;k++) { a=a1; } N = N (~a); printf(value of N is %d,N); for(k=0;ki;k++) M=M1; N=N|M; printf(value of N is %d,N); getchar(); } isnt it give us wrong mask say i=2; j=6; it gives mask as(i.e ~a) 0011 but i think from 2 to 6 5 0's are neededplz tell the above prog is ok???or not???check by giving any input whose 7thy bit is set...thnx in advance -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Adobe Question
if sorted then a tweak in merge sort will work On 20 January 2011 23:23, nishaanth nishaant...@gmail.com wrote: Ya as Ashish said hashing is the best solution :) On Fri, Jan 14, 2011 at 6:00 PM, Ashish Goel ashg...@gmail.com wrote: ideally, a hashMap would be preferred walk through one array and set the corresponding entry, and then through another array, if any entry found, then they are not disjoint. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jan 14, 2011 at 3:35 PM, bittu shashank7andr...@gmail.comwrote: how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. 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.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 algogeeks@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. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.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 algogeeks@googlegroups.com. To unsubscribe from 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] Adobe Question
how merge sort ?/ On Thu, Jan 20, 2011 at 11:23 PM, nishaanth nishaant...@gmail.com wrote: Ya as Ashish said hashing is the best solution :) On Fri, Jan 14, 2011 at 6:00 PM, Ashish Goel ashg...@gmail.com wrote: ideally, a hashMap would be preferred walk through one array and set the corresponding entry, and then through another array, if any entry found, then they are not disjoint. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jan 14, 2011 at 3:35 PM, bittu shashank7andr...@gmail.comwrote: how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. 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.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 algogeeks@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. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.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 algogeeks@googlegroups.com. To unsubscribe from 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] Adobe Question
if both arrray are sorted. take two ptrs, one pointing to a[0] other to b[0]. if elements are same then nt disjoint. else increment ptr pointing to smaller element until it becomes equal or greater than the element pointed by other. repeat until either ptr reaches end of array.. On 21 January 2011 21:42, Manmeet Singh mans.aus...@gmail.com wrote: how merge sort ?/ On Thu, Jan 20, 2011 at 11:23 PM, nishaanth nishaant...@gmail.com wrote: Ya as Ashish said hashing is the best solution :) On Fri, Jan 14, 2011 at 6:00 PM, Ashish Goel ashg...@gmail.com wrote: ideally, a hashMap would be preferred walk through one array and set the corresponding entry, and then through another array, if any entry found, then they are not disjoint. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jan 14, 2011 at 3:35 PM, bittu shashank7andr...@gmail.comwrote: how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. 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.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 algogeeks@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. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.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 algogeeks@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 algogeeks@googlegroups.com. To unsubscribe from 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] Adobe Question
Ya as Ashish said hashing is the best solution :) On Fri, Jan 14, 2011 at 6:00 PM, Ashish Goel ashg...@gmail.com wrote: ideally, a hashMap would be preferred walk through one array and set the corresponding entry, and then through another array, if any entry found, then they are not disjoint. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jan 14, 2011 at 3:35 PM, bittu shashank7andr...@gmail.com wrote: how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. 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.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 algogeeks@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. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Adobe Question
how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. 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.
Re: [algogeeks] Adobe Question
are they sorted? On Fri, Jan 14, 2011 at 3:35 PM, bittu shashank7andr...@gmail.com wrote: how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. 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.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 algogeeks@googlegroups.com. To unsubscribe from 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] Adobe Question
ideally, a hashMap would be preferred walk through one array and set the corresponding entry, and then through another array, if any entry found, then they are not disjoint. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jan 14, 2011 at 3:35 PM, bittu shashank7andr...@gmail.com wrote: how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. 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.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 algogeeks@googlegroups.com. To unsubscribe from 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] Adobe Question
Integers larger than which fit in 32/64 bits. On Thu, Jan 13, 2011 at 8:58 PM, bittu shashank7andr...@gmail.com wrote: 1. 10 test cases for entering 3 values representing sides of a triangle and the program giving output as scalene, isosceles or equilateral--Means At Least 10 2 .Question on a program that calculates P=R/I where R, I are integer inputs and P a floating point output. Write 10 test cases for thisAt Least 10 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.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 algogeeks@googlegroups.com. To unsubscribe from 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] Adobe Question
1. 10 test cases for entering 3 values representing sides of a triangle and the program giving output as scalene, isosceles or equilateral--Means At Least 10 2 .Question on a program that calculates P=R/I where R, I are integer inputs and P a floating point output. Write 10 test cases for thisAt Least 10 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.
[algogeeks] Adobe Question
You have a array of 0's and 1's. e.g. 0001011101001010100101010101100111 Find the maximum contiguous subsequence of the above sequence so the number of 0's and 1's in that subsequence are equal 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 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] Adobe Question
will an o(n^2) do ? , i have one in mind but will that suffice ? anyways , here it goes make array a[array_length][2]; a[k][0] and a[k][1] will contain the no. of 0's and 1 till kth position. just iterate twice to see where a[i][0]-a[j][0]==a[i][1]-a[j][1] can be maximized . meanwhile i am thinking of other solution . . . . On Tue, Jan 4, 2011 at 2:08 PM, bittu shashank7andr...@gmail.com wrote: You have a array of 0's and 1's. e.g. 0001011101001010100101010101100111 Find the maximum contiguous subsequence of the above sequence so the number of 0's and 1's in that subsequence are equal 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 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] Adobe Question
maximum sub sequence whose sum is half of the sub sequence length. On Tue, Jan 4, 2011 at 2:08 PM, bittu shashank7andr...@gmail.com wrote: You have a array of 0's and 1's. e.g. 0001011101001010100101010101100111 Find the maximum contiguous subsequence of the above sequence so the number of 0's and 1's in that subsequence are equal 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 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] Adobe Question
Assuming A[1..n] i=1,j=n calculate the initial sum and length of array let it be s and l now if s l/2 then { .if a[i]=1 then i++ .elseif a[j]=1 then j++ .else i++ } if s l/2 then { .if a[i]=0 then i++ .elseif a[j]=0 then j++ .else i++ } if s=l/2 then it (i,j) is ur answer i dont know it works for sure or not but its an O(n) On Tue, Jan 4, 2011 at 2:08 PM, bittu shashank7andr...@gmail.com wrote: You have a array of 0's and 1's. e.g. 0001011101001010100101010101100111 Find the maximum contiguous subsequence of the above sequence so the number of 0's and 1's in that subsequence are equal 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 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 Aditya Kumar B-tech 3rd year Computer Science Engg. 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Adobe question
You have an array consisting of 2n+1 elements, n elements in it are married, i.e they occur twice in the array, however there is one element which only appears once in the array. You need to find that number in a single pass using constant memory,assuming that all are positive numbers. 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 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.
[algogeeks] Adobe question
Given 2 array in first array n elements are sorted there in second elements n+1 elements and n elements in 2nd array not ordered and it also contains one extra elements wap to find out extra elements in one pass. Regards Shashank Mani BIT Mesra -- 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.
[algogeeks] Adobe Question
for(k=1 ; kn ; k++){ j=k; while(j0){ j=j/2; } } How many times while loop gets executed (for any n) ? I don't want answer in terms of series (i.e, don't want any sigma, I have that) -- 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] Adobe Question
what is the data type of 'j' ? On Thu, Sep 23, 2010 at 6:49 PM, Krunal Modi krunalam...@gmail.com wrote: for(k=1 ; kn ; k++){ j=k; while(j0){ j=j/2; } } How many times while loop gets executed (for any n) ? I don't want answer in terms of series (i.e, don't want any sigma, I have that) -- 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 Apoorve Mohan -- 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] Adobe Question
@Davefor n=2 ur formulae would give 1 but the result is 3 On Thu, Sep 23, 2010 at 6:53 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: what is the data type of 'j' ? On Thu, Sep 23, 2010 at 6:49 PM, Krunal Modi krunalam...@gmail.comwrote: for(k=1 ; kn ; k++){ j=k; while(j0){ j=j/2; } } How many times while loop gets executed (for any n) ? I don't want answer in terms of series (i.e, don't want any sigma, I have that) -- 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 Apoorve Mohan -- 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. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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] Adobe Question
@nishaanth for n=1 N=0 as k=1 and kn not k=n for n=2 N= 0+1 for n=3 N=0+1+3 so formula is correct .. i have checked twice @Dave : very nice but... how u approached while solving On Thu, Sep 23, 2010 at 12:29 PM, nishaanth nishaant...@gmail.com wrote: @Davefor n=2 ur formulae would give 1 but the result is 3 On Thu, Sep 23, 2010 at 6:53 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: what is the data type of 'j' ? On Thu, Sep 23, 2010 at 6:49 PM, Krunal Modi krunalam...@gmail.comwrote: for(k=1 ; kn ; k++){ j=k; while(j0){ j=j/2; } } How many times while loop gets executed (for any n) ? I don't want answer in terms of series (i.e, don't want any sigma, I have that) -- 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 Apoorve Mohan -- 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. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base
i guess the problem is just told in different format observe careful it is converting a number into the given base(limit given). -- Thanks Regards Rajesh Patidar On 17-08-2010 21:50, luckyzoner wrote: I had proposed an algorithm of repeatedly subtracting 1 from the given number and subsequently adding 1 to the new number initialised to 0, till the given number becomes 0. However as soon as the digit reaches the limit , the digit becomes 0 and you add 1 to the next digit. I was not able to code it properly as i had to use int data type only. It would have been easy if the array of integers was allowed to use. Pls suggest the code for the same or some better algo. Thanx Lakshaya -- 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. inline: signature.png
Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base
Below formula seems working to me for converting number from base B1 to base B2. But For intermediate operation we have to be careful, as comiler does all operation with base 10. newNum = (oldNum/newBase)*oldBase + oldNum%newBase; So Algo, 1. Number, oldBase, newbase; 2. First convert number from oldBase to base 10, TempNumber. [same above formula, newBase = 10, oldBase = B1] 3. Now, Convert TempNumber from base 10 to base B2. [same above formula, newBase = B2, oldBase = 10] ==Number. On Tue, Aug 17, 2010 at 9:50 PM, luckyzoner luckyzo...@gmail.com wrote: I had proposed an algorithm of repeatedly subtracting 1 from the given number and subsequently adding 1 to the new number initialised to 0, till the given number becomes 0. However as soon as the digit reaches the limit , the digit becomes 0 and you add 1 to the next digit. I was not able to code it properly as i had to use int data type only. It would have been easy if the array of integers was allowed to use. Pls suggest the code for the same or some better algo. Thanx Lakshaya -- 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] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base
It is not clear whether 'subtraction' operation for given base B1 is granted defined or you should write code for it. If it is already defined, then simulating division (working wrt base B1) is easy (repeated subtraction). Then the normal procedure of converting a number from base 10 to base b2 would work, where you divide the number by B2, note down the remainder, replace dividend by the quotient and repeat the process until the dividend becomes zero. Finally you concatenate the remainders in the reverse order. Ex: From 214 of base 5 to base 16. 16 is 31 of base 5 so, 214 / 31 =* **3* ; 214 % 31 = 21; [ / and % work wrt base 5 which is to be programmed using repeated subtraction ] *3* / 31 = 0 ; 3 % 31 = 3; finally 3,21 or 3B coz B is hex equivalent of 21_base5 OR in your simpler algo, is it not possible to define functions that 'get' and 'set' a particular digit, by using / and % ? Thanks, Summ On Tue, Aug 17, 2010 at 9:50 PM, luckyzoner luckyzo...@gmail.com wrote: I had proposed an algorithm of repeatedly subtracting 1 from the given number and subsequently adding 1 to the new number initialised to 0, till the given number becomes 0. However as soon as the digit reaches the limit , the digit becomes 0 and you add 1 to the next digit. I was not able to code it properly as i had to use int data type only. It would have been easy if the array of integers was allowed to use. Pls suggest the code for the same or some better algo. Thanx Lakshaya -- 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] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base
Hi example (83)base 5 -- ()base7 num temp_num resultcarry 83 3* 1 (3/7) =0(3%7)=3 838*5 (40/7)=5 (40%7)=5 result=0+5=5 carry= 3+5=8 temp_carry=call convert for carry in which base is 10 and target base is 7 (temp_carry will become 11) carry=temp_carry%10; (carry will become 1) result=result +temp_carry/10; (result will become 6) call convert for result in which base is 10 and target base is 7 (result remain 6) result=result*10 + carry result 61 return result The logic would remain same for hexadecimal base also but implementation would differ On Wed, Aug 18, 2010 at 6:41 PM, sumant hegde sumant@gmail.com wrote: It is not clear whether 'subtraction' operation for given base B1 is granted defined or you should write code for it. If it is already defined, then simulating division (working wrt base B1) is easy (repeated subtraction). Then the normal procedure of converting a number from base 10 to base b2 would work, where you divide the number by B2, note down the remainder, replace dividend by the quotient and repeat the process until the dividend becomes zero. Finally you concatenate the remainders in the reverse order. Ex: From 214 of base 5 to base 16. 16 is 31 of base 5 so, 214 / 31 =* **3* ; 214 % 31 = 21; [ / and % work wrt base 5 which is to be programmed using repeated subtraction ] *3* / 31 = 0 ; 3 % 31 = 3; finally 3,21 or 3B coz B is hex equivalent of 21_base5 OR in your simpler algo, is it not possible to define functions that 'get' and 'set' a particular digit, by using / and % ? Thanks, Summ On Tue, Aug 17, 2010 at 9:50 PM, luckyzoner luckyzo...@gmail.com wrote: I had proposed an algorithm of repeatedly subtracting 1 from the given number and subsequently adding 1 to the new number initialised to 0, till the given number becomes 0. However as soon as the digit reaches the limit , the digit becomes 0 and you add 1 to the next digit. I was not able to code it properly as i had to use int data type only. It would have been easy if the array of integers was allowed to use. Pls suggest the code for the same or some better algo. Thanx Lakshaya -- 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. -- Rahul singhal RnD Engineer Tejas Networks Mobile- 09916969422 -- 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.
[algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base
I had proposed an algorithm of repeatedly subtracting 1 from the given number and subsequently adding 1 to the new number initialised to 0, till the given number becomes 0. However as soon as the digit reaches the limit , the digit becomes 0 and you add 1 to the next digit. I was not able to code it properly as i had to use int data type only. It would have been easy if the array of integers was allowed to use. Pls suggest the code for the same or some better algo. Thanx Lakshaya -- 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.