Re: [algogeeks] facebook
thanks for the info DK. On Wed, Jul 6, 2011 at 11:21 AM, DK divyekap...@gmail.com wrote: I've gone through their process. The questions are simpler than those for Google but they look for a different set of qualities in their hires than Google so your CV and reccos (if asked) are important. I'm posting via mobile so I cant post any questions right now. -- DK -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/5ReWQc7gkxEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. The road to knowledge runs through the land of confusion. Mobile: +91 9844667142 Email : hc4...@gmail.com http://www.facebook.com/profile.php?id=1518764305 https://twitter.com/#!/harshal4342 http://www.linkedin.com/pub/harshal-choudhary/17/731/291 http://kkoolharshal.blogspot.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MS
things to consider 1. priority(static, dynamic(based on wait and usage time), priority boost) 2. busy hrs vrs non-busy hrs stop time 3. when idle, should stop at highest traffic generation floor 4. weight factor to decide if to stop or not 5. multiple elevators, some for lower floors, some for upper floors only, co-ordination between elevators Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jun 14, 2011 at 2:01 PM, Akshata Sharma akshatasharm...@gmail.comwrote: Design an elevator system for a 100 story building. Address all issues, like number of elevators, speed of each (Not numerically), waiting times etc. There would be 100-200 people living/working on each floor. (You don't need to discuss the traffic patterns.) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] MS Question
See diff documentation. It's an application of Longest Common Subsequence problem. http://en.wikipedia.org/wiki/Diff On Wed, Jul 6, 2011 at 11:12 AM, priyanshu priyanshuro...@gmail.com wrote: What is the most efficient way to compare two text documents?? Also we need to find the percentage by which they match.. Thanks, priyanshu -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort - Consecutive Array in O(n)
Check this *int isconsecutive(int a[], int n) {* *if (n 1) {* *return 0;* *}* *int max = a[0], min = a[0];* *int i = 0;* * * *int *hash = (int*) calloc(n, sizeof (int));* * * *//find min and max from the array* *for (i = 1; i n; i++) {* *if (a[i] min)* *min = a[i];* *else if (a[i] max)* *max = a[i];* *}* * * *if (max - min + 1 != n)* *return 0;* * * *for (i = 0; i n; i++) {* *if (hash[a[i] - min + 1] == 1)* *return 0;* *hash[a[i] - min + 1] = 1;* *}* *return 1;* * * *}* * * *int main(int argc, char** argv) {* * * *int a[] = {-1, 0,1,2, 4, 3, 5};* *int n = sizeof (a) / sizeof (a[0]);* *printf(%d, isconsecutive(a, n));* * * *return (EXIT_SUCCESS);* *}* On Sat, Jun 25, 2011 at 1:14 AM, ross jagadish1...@gmail.com wrote: Given an array, A, find if all elements in the sorted version of A are consecutive in less than O(nlogn). eg: A: 5 4 1 2 3 on sorting 1 2 3 4 5 all elements are consecutive -- true A: 1 9 2 22 on sorting 1 2 9 22 all elements are NOT consecutive - false -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: meaning of null in output
#includestdio.h int main () { int * p = NULL ; printf ( %s , p ) ; getchar () ; } On Sat, Jul 2, 2011 at 3:33 AM, hary rathor harry.rat...@gmail.com wrote: Rajeev : please can u explain by a c example ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
Can you make a target number 37 by using five 5s? You can use any math operator as you want. There are at least two different ways. 5 5 5 5 5 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
On Wed, Jul 6, 2011 at 1:23 PM, amit the cool amitthecoo...@gmail.comwrote: Can you make a target number 37 by using five 5s? You can use any math operator as you want. There are at least two different ways. 5 5 5 5 5 (((5+5)/5)^5)+5 ((10/5)^5)+5 (2^5)+5 32+5=37 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks and Regards *Karan Bagaria* *MCA Final Year* Training and Placement Representative *NIT Durgapur* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] NVIDIA Q
What is the size of an object of a class with no members in it?? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] NVIDIA Q
The size will be 1 byte as there is nothing to look into the object. And it is 1 instead of zero because two objects of the class will have different addresses by assigning each object size 1. Regards, Durga On Wed, Jul 6, 2011 at 2:11 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: What is the size of an object of a class with no members in it?? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] NVIDIA Q
thanks buddy..:) On 7/6/11, durgaprasad k durga...@gmail.com wrote: The size will be 1 byte as there is nothing to look into the object. And it is 1 instead of zero because two objects of the class will have different addresses by assigning each object size 1. Regards, Durga On Wed, Jul 6, 2011 at 2:11 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: What is the size of an object of a class with no members in it?? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] NVIDIA Q
it is 8 bytes if you are talking about a java class On Wed, Jul 6, 2011 at 2:27 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: thanks buddy..:) On 7/6/11, durgaprasad k durga...@gmail.com wrote: The size will be 1 byte as there is nothing to look into the object. And it is 1 instead of zero because two objects of the class will have different addresses by assigning each object size 1. Regards, Durga On Wed, Jul 6, 2011 at 2:11 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: What is the size of an object of a class with no members in it?? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Sort - Consecutive Array in O(n)
How about doing like this ?. Without loss of generality, I can assume that numbers starts from 1 (if not, if it starts from ZERO, add by 1 to all the numbers, if it is negative, find the min value, assume it is X, add by (-X)+1)) Now assume numbers are M, compute the product of the numbers and compute M! and check if they are equal. does it work ? Thanks, Sathaiah On Wed, Jul 6, 2011 at 11:45 AM, Anantha Krishnan ananthakrishnan@gmail.com wrote: Check this *int isconsecutive(int a[], int n) {* *if (n 1) {* *return 0;* *}* *int max = a[0], min = a[0];* *int i = 0;* * * *int *hash = (int*) calloc(n, sizeof (int));* * * *//find min and max from the array* *for (i = 1; i n; i++) {* *if (a[i] min)* *min = a[i];* *else if (a[i] max)* *max = a[i];* *}* * * *if (max - min + 1 != n)* *return 0;* * * *for (i = 0; i n; i++) {* *if (hash[a[i] - min + 1] == 1)* *return 0;* *hash[a[i] - min + 1] = 1;* *}* *return 1;* * * *}* * * *int main(int argc, char** argv) {* * * *int a[] = {-1, 0,1,2, 4, 3, 5};* *int n = sizeof (a) / sizeof (a[0]);* *printf(%d, isconsecutive(a, n));* * * *return (EXIT_SUCCESS);* *}* On Sat, Jun 25, 2011 at 1:14 AM, ross jagadish1...@gmail.com wrote: Given an array, A, find if all elements in the sorted version of A are consecutive in less than O(nlogn). eg: A: 5 4 1 2 3 on sorting 1 2 3 4 5 all elements are consecutive -- true A: 1 9 2 22 on sorting 1 2 9 22 all elements are NOT consecutive - false -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Sort - Consecutive Array in O(n)
@ Sathaiah Dontula i think this won't work Because product of m consecutive integers is divisible by m! but reverse is not true ie. if product of m integers is divisible by m! then they are consecutive ?? correct me if i am wrong!! On Wed, Jul 6, 2011 at 12:55 PM, Sathaiah Dontula don.sat...@gmail.comwrote: How about doing like this ?. Without loss of generality, I can assume that numbers starts from 1 (if not, if it starts from ZERO, add by 1 to all the numbers, if it is negative, find the min value, assume it is X, add by (-X)+1)) Now assume numbers are M, compute the product of the numbers and compute M! and check if they are equal. does it work ? Thanks, Sathaiah On Wed, Jul 6, 2011 at 11:45 AM, Anantha Krishnan ananthakrishnan@gmail.com wrote: Check this *int isconsecutive(int a[], int n) {* *if (n 1) {* *return 0;* *}* *int max = a[0], min = a[0];* *int i = 0;* * * *int *hash = (int*) calloc(n, sizeof (int));* * * *//find min and max from the array* *for (i = 1; i n; i++) {* *if (a[i] min)* *min = a[i];* *else if (a[i] max)* *max = a[i];* *}* * * *if (max - min + 1 != n)* *return 0;* * * *for (i = 0; i n; i++) {* *if (hash[a[i] - min + 1] == 1)* *return 0;* *hash[a[i] - min + 1] = 1;* *}* *return 1;* * * *}* * * *int main(int argc, char** argv) {* * * *int a[] = {-1, 0,1,2, 4, 3, 5};* *int n = sizeof (a) / sizeof (a[0]);* *printf(%d, isconsecutive(a, n));* * * *return (EXIT_SUCCESS);* *}* On Sat, Jun 25, 2011 at 1:14 AM, ross jagadish1...@gmail.com wrote: Given an array, A, find if all elements in the sorted version of A are consecutive in less than O(nlogn). eg: A: 5 4 1 2 3 on sorting 1 2 3 4 5 all elements are consecutive -- true A: 1 9 2 22 on sorting 1 2 9 22 all elements are NOT consecutive - false -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] NVIDIA Q
that is why i mentioned if you are talking about a 'java class' On Wed, Jul 6, 2011 at 2:39 PM, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: It is a more standard question when we consider c++,as the minimum size of any object is 1 byte. On Wed, Jul 6, 2011 at 2:35 PM, Gunjan Agarwal gunjanagarwal1...@gmail.com wrote: it is 8 bytes if you are talking about a java class On Wed, Jul 6, 2011 at 2:27 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: thanks buddy..:) On 7/6/11, durgaprasad k durga...@gmail.com wrote: The size will be 1 byte as there is nothing to look into the object. And it is 1 instead of zero because two objects of the class will have different addresses by assigning each object size 1. Regards, Durga On Wed, Jul 6, 2011 at 2:11 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: What is the size of an object of a class with no members in it?? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] puzzle
thanx guys On Wed, Jul 6, 2011 at 2:40 PM, udit sharma sharmaudit...@gmail.com wrote: (5*5)+(!5)/(5+5) and (((5+5)/5)^5)+5 -- Regards UDIT DU- MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Longest substring 0's 1's
excellent solution sunny On Tue, Jul 5, 2011 at 11:44 PM, amit kumar amitthecoo...@gmail.com wrote: #includestdio.h #define n 11 int main() { int ar[n]={1,0,1,1,1,0,0,0,0,0,1}; int a[n][n]; int l,i,k,maxlength=0,start,end; for(i=0;in;i++) { ar[i]==0?(a[i][i]=-1):(a[i][i]=1); } for(l=2;l=n;l++) { for(i=0;i=n-l;i++) { for(k=i;ki+l-1;k++) { a[i][i+l-1]=a[i][k]+a[k+1][i+l-1]; if(a[i][i+l-1]==0 lmaxlength) { maxlength=l; start=i; end=i+l-1; } } } } printf(maxm length=%d\n,maxlength); for(i=start;i=end;i++) printf(%d ,ar[i]); } On Tue, Jul 5, 2011 at 11:49 AM, Kunal Patil kp101...@gmail.com wrote: @Sunny : Excellent !!! Keep posting such nice solutions !! :) On Sat, Jul 2, 2011 at 1:47 AM, Anika Jain anika.jai...@gmail.comwrote: ohh ok i got it.. thanx :) On Sat, Jul 2, 2011 at 12:48 AM, sunny agrawal sunny816.i...@gmail.comwrote: it is (2,4] not [2,4]. open interval, close interval . consider (i,j] as [i+1,j] because a[i] = sum of values from 0 to i and a[j] = sum of values from 0 to j if a[i] = a[j] then it means sum does not changes between a[i] to a[j] so from i+1 to j there are equal no of 1's and -1's or in other words equal no of 0's and 1's On Sat, Jul 2, 2011 at 12:42 AM, Anika Jain anika.jai...@gmail.comwrote: @sunny: in a[2,4] has 2 1s and one 0 then how is it a solution? i mean i didnt get wen a[i]==a[j] then a[i,j] is a solution case.. On Fri, Jul 1, 2011 at 4:13 PM, sunny agrawal sunny816.i...@gmail.com wrote: Take an array of size of the length of the string. fill the array positions with one where string contains 1, and -1 where it is 0 Now for each i (1,n-1) perform the following operation a[i] = a[i-1] + a[i] now a[i] will contains sum of values from a[0] to a[i] in original array. Now only thing remains to find is two indexes in this array such that a[i] = a[j] where ever this condition is met ( i,j ] is a solution or if for some i a[i] = 0 in this case [0,i] will be a solution this can be done using hashing hash the values in the array of size 2*n+1. as range of values is -n to n and keep track of max interval. On Fri, Jul 1, 2011 at 3:22 PM, Anantha Krishnan ananthakrishnan@gmail.com wrote: Given a string containing 0's and 1's. One would need to find the longest sub-string such that the count of 0's is equal to the count of 1's in the largest sub string. Regards Anantha Krishnan -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
Re: [algogeeks] Re: VIRTUAL INHERITANCE
@oppilas In normal inheritance base class is not shared. Each derived class X and Y have separate instance of base class. The whole point of virtual inheritance is sharing so that there shall be no ambiguity as there is only one object of base class. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/W0v32oYHO0IJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Some adobe interview questions.
very nice link for questions of type Q9. http://pw1.netcom.com/~tjensen/ptr/ch9x.htm -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/0ngOncUXrRYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Some adobe interview questions.
Q1. First sort both the strings using counting sort perhaps. Then starting from the first character, search for it in the second string using binary search. The succeeding character of A will be searched from the index in B at which last character of A was found Worst case: When both the strings are alike : O(log(m) + log(m-1) + log(m-2) ...log(1)) = O(m*log(m)) But Average case will be quite efficient Abhishek Khattri, Computer Engineering, Netaji Subhas Institute of Technology -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/vo0EQrVjxBUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: help to code
Evenly divisible simply means that a number should be completely divisible by the given numbers, i.e., it should give a whole number as an answer when divided by that particular number. Evenly divisible doesn't mean that quotient should be an even number. It just needs to be a whole number. Probably this link can help you understand that http://en.wiktionary.org/wiki/evenly_divisible So if you agree with my interpretation that numbers which are not divisible by all 5 numbers should be taken into account, then my code is correct. :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Some adobe interview questions.
Sol for Q4 int pallindrome(char *str) { static length = strlen(str); if(length 1) return 1; if(str[0] == str[length-1]) { length -= 2; return pallindrome(str+1); } else return 0; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/WwBB4MUlTWMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] solve this
Solve Dis! A Boy Forgot His Pin-Code Which Was Of 5 Digits, But Luckily He Remembered Some Hints How To 2 Remind That Password, ...Here Are Those Clues. 1.First Digit Is Equal To The Square Of Second Digit 2.Second Plus 3rd Digit Are Equal To 10 3.4th Digit Equal To The 2nd Digit Plus 1 4.5th Plus 3rd Digit Make 14 5.Sum Of All The Five Digit Make 30. Find The Pin Code -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] solve this
93747. Just defined the variables as x^2, x, y, x+1, 14-y and solved it with information in 5th statement. On Wed, Jul 6, 2011 at 5:28 PM, rupali chauhan chauhanrupal...@gmail.com wrote: Solve Dis! A Boy Forgot His Pin-Code Which Was Of 5 Digits, But Luckily He Remembered Some Hints How To 2 Remind That Password, ...Here Are Those Clues. 1.First Digit Is Equal To The Square Of Second Digit 2.Second Plus 3rd Digit Are Equal To 10 3.4th Digit Equal To The 2nd Digit Plus 1 4.5th Plus 3rd Digit Make 14 5.Sum Of All The Five Digit Make 30. Find The Pin Code -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] solve this
93747.. -- Regards UDIT DU- MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] solve this
93747 On Wed, Jul 6, 2011 at 5:28 PM, rupali chauhan chauhanrupal...@gmail.comwrote: Solve Dis! A Boy Forgot His Pin-Code Which Was Of 5 Digits, But Luckily He Remembered Some Hints How To 2 Remind That Password, ...Here Are Those Clues. 1.First Digit Is Equal To The Square Of Second Digit 2.Second Plus 3rd Digit Are Equal To 10 3.4th Digit Equal To The 2nd Digit Plus 1 4.5th Plus 3rd Digit Make 14 5.Sum Of All The Five Digit Make 30. Find The Pin Code -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
Why is it suggested not to use malloc() or calloc() in C++ for memory allocation? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
I think C++ has some advanced feature for memory allocation like new. On Wed, Jul 6, 2011 at 6:34 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: Why is it suggested not to use malloc() or calloc() in C++ for memory allocation? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Regards, Tamanna -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 reason is graduation. Since C++ is object oriented and designers wanted to provide more safety in case of dynamic memory allocations, they defined new and delete operators to handle allocation and deallocation. If you see malloc, if does only one function - allocate the memory, with new operator on an object, it's appropriate constuctor will be called and you are guaranteed with proper initialization specially when we use standard libraries. So new faciliates allocation as well as initialization, similarly delete faciliates deallocation as well as destruction (clean up code inside destructor function). With free, user won't be having any handle on object if allocated with new until it is allocated memory and appropriately initialized. Also, AFAIK, chances of getting proper memory allocation are more with new than malloc. Somebody on the group may confirm. On Wed, Jul 6, 2011 at 6:07 PM, Tamanna Afroze afroze...@gmail.com wrote: I think C++ has some advanced feature for memory allocation like new. On Wed, Jul 6, 2011 at 6:34 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: Why is it suggested not to use malloc() or calloc() in C++ for memory allocation? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Regards, Tamanna -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Design questions in interviews
Hi all , Can someone point to some websites where you can find cs design questions ? Eg. Design a data structure for sparse matrix ? -- regards, chinna. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Grouop activity
Hi All, This group is very active and useful. Very useful to shre information related to algorithms, its problem and solution. -- Best Regards, *Tamanna Afroze* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] solve this
93747 On Wed, Jul 6, 2011 at 5:05 AM, anurag aggarwal anurag19aggar...@gmail.comwrote: 93747 On Wed, Jul 6, 2011 at 5:28 PM, rupali chauhan chauhanrupal...@gmail.comwrote: Solve Dis! A Boy Forgot His Pin-Code Which Was Of 5 Digits, But Luckily He Remembered Some Hints How To 2 Remind That Password, ...Here Are Those Clues. 1.First Digit Is Equal To The Square Of Second Digit 2.Second Plus 3rd Digit Are Equal To 10 3.4th Digit Equal To The 2nd Digit Plus 1 4.5th Plus 3rd Digit Make 14 5.Sum Of All The Five Digit Make 30. Find The Pin Code -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Some adobe interview questions.
Yes I am also getting the same. On Jul 5, 12:50 am, Ritesh Srivastava riteshkumar...@gmail.com wrote: For Q3 . Sum of all the digits should be 8. I think , 42101000 is an answer. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Puzzle
Hi, A son and father goes for boating in river upstream . After rowing for 1 mile son notices the hat of his fathe falling in the river.After 5 min. he tells his father that his hat has fallen. So they turn round and are able to pick the hat at the point from where they began boating after 5min. Tell the speed of river? The answer is 6miles/hr. Can anyone say how..?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Reason for banning
Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Some adobe interview questions.
what about 7? 7 occurred once right? On Jul 6, 12:32 am, aditya kumar aditya.kumar130...@gmail.com wrote: in 7000 : '0' occurs seven times and rst of the numbers occur zero times. i still dint get where i am wrong . plz explain me . On Wed, Jul 6, 2011 at 12:47 AM, L prnk.bhatna...@gmail.com wrote: @aditya : I am wondering how many times 7 has occurred. Is it 1? Or is it 0? Please take a moment before posting your solution, and think whether it is write or wrong! On Jul 6, 12:11 am, aditya kumar aditya.kumar130...@gmail.com wrote: Q3. ans:7000 i guess this is also a correct answer and no unique soln as such On Wed, Jul 6, 2011 at 12:37 AM, aditya kumar aditya.kumar130...@gmail.comwrote: boolean palindromeCheck(String string) { len=string.length(); if((string.length()1)) { if((string.charAt(0)==string.charAt(len-1))) { str=; str=str+string.substring(1,(len-1)); palindromeCheck(str); } else { flag=false; } } return flag; } THis also works fine if you dont want to use pointer On Tue, Jul 5, 2011 at 9:37 PM, Azhar Hussain azhar...@gmail.com wrote: For Q4: I think this is the optimal code int recurPalin(char *start, char *end) { if (end start) return true; if (*start != *end) return false; return recurPalin(start+1, end-1); } - Azhar. On Tue, Jul 5, 2011 at 12:21 PM, vikas mehta...@gmail.com wrote: My program for Q4. // recursively find if a given string is palindrome bool IsPalindrome(string s, int start, int start2, bool flag) { bool flag1 = flag; if (start = 0 start2 (s.Length)) { char c1 = s[start]; char c2 = s[start2]; if (c1.Equals(c2)) { if (start == 0 start2 == s.Length - 1) { flag = true; } if (IsPalindrome(s, start - 1, start2 + 1, flag)) { flag1 = true; } } } return flag1; } while calling if (s.Length % 2 != 0) { p.IsPalindrome(s, s.Length / 2 - 1, s.Length / 2 + 1, false); } else { p.IsPalindrome(s, s.Length / 2 - 1, s.Length / 2, false); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/I6SVTB0o-uUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Sort - Consecutive Array in O(n)
a) Find min(A). - O(n) b) Find max(A) - O(n) c) Calculate sum of natural numbers starting from min(A) to max(A) - O(n) d) Calculate sum of all numbers in the array. - O(n) e) If sum in step c) is not same as sum in step d), then elements are not consecutive. If the sum is same, then they are consecutive. Can anyone think of a counterexample that breaks the above algo. On Jul 6, 8:25 am, Sathaiah Dontula don.sat...@gmail.com wrote: How about doing like this ?. Without loss of generality, I can assume that numbers starts from 1 (if not, if it starts from ZERO, add by 1 to all the numbers, if it is negative, find the min value, assume it is X, add by (-X)+1)) Now assume numbers are M, compute the product of the numbers and compute M! and check if they are equal. does it work ? Thanks, Sathaiah On Wed, Jul 6, 2011 at 11:45 AM, Anantha Krishnan ananthakrishnan@gmail.com wrote: Check this *int isconsecutive(int a[], int n) {* * if (n 1) {* * return 0;* * }* * int max = a[0], min = a[0];* * int i = 0;* * * * int *hash = (int*) calloc(n, sizeof (int));* * * * //find min and max from the array* * for (i = 1; i n; i++) {* * if (a[i] min)* * min = a[i];* * else if (a[i] max)* * max = a[i];* * }* * * * if (max - min + 1 != n)* * return 0;* * * * for (i = 0; i n; i++) {* * if (hash[a[i] - min + 1] == 1)* * return 0;* * hash[a[i] - min + 1] = 1;* * }* * return 1;* * * *}* * * *int main(int argc, char** argv) {* * * * int a[] = {-1, 0,1,2, 4, 3, 5};* * int n = sizeof (a) / sizeof (a[0]);* * printf(%d, isconsecutive(a, n));* * * * return (EXIT_SUCCESS);* *}* On Sat, Jun 25, 2011 at 1:14 AM, ross jagadish1...@gmail.com wrote: Given an array, A, find if all elements in the sorted version of A are consecutive in less than O(nlogn). eg: A: 5 4 1 2 3 on sorting 1 2 3 4 5 all elements are consecutive -- true A: 1 9 2 22 on sorting 1 2 9 22 all elements are NOT consecutive - false -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] قروب مملكة الجنس x2020x
banned !!! this is why people get banned :D 2011/7/6 m love d d love m almouhnad2...@gmail.com [image: http://4.bp.blogspot.com/-3SaLDKOYNrk/ThRiSbWaLlI/AAU/czfZbRx-PHk/s1600/00.jpg] * قروب مملكة الجنس* *للاشتراك ارسل رسالة فارغة على الايميل * * x2020x+subscr...@googlegroups.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] Re: Reason for banning
it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Some adobe interview questions.
You have given solution for number of coins required for different sum as explained on topcoder tutorial. But I think the question has put forward some conditions based on which it asks us to find the denominations of the 6 coins. You have taken the sum given(which cannot be obtained by using coins we have) in the problem as denominations. I think you have interpreted it erongly. Just hope my interpretation is correct :) On Tue, Jul 5, 2011 at 5:25 PM, Azhar Hussain azhar...@gmail.com wrote: What I understood from the statement is what is the 'minimum denomination' required for a given value. I will try to explain it in short we can solve the problem as sub-problems Lets say you want a denomination for some sum S and 'i' be the previous sum so i = S. If we can find the sum at i we can find the sum for i+1 using i as our reference. For example S= 15. What is the minimum denomination required using the coins 5, 10 from the statement above I cannot calculate sums other than multiples of 5. So, I will write down sums which are multiples of 5 upto 15. 0 5 10 15 Inorder to calculate denominations for 15. I must have calculate denominations of 15, 5, 0 Goal: First 0, this does not require coins so coins are 0. Sum 5, we have found the solution yet for this mark it as infinity. We see that there is only one coin in the denomination pool which is less than this sum. Sum 10, If I can take the previous sum 10 - 5, I will end up having 2 coins but the best solution would be denomination of 10 i.e., 1 coin. I compare the denominations value and the previous sum and store the minimum value. Sum 15, From the previous step 1 coin for 10 and 5 denomination will make up the sum so number of coins are 2. this can be recursively defined as if ((N[j] = i) ((Min[i-N[j]] + 1) Min[i])) Min[i] = Min[i-N[j]] + 1; Where N is the denominations i is the Previous Sum denoted as Min j is the index of denomination sum[1,, 15] = infinity; for sum 0 i = 0; N[0] = 5 and 5 = is false sum remains 0, so Sum[0] = 0. for Sum 5 i = 5 ; N[0] = 5 and 5 = 5 true and (Sum[5-5] + 1) Sum[5] update the sum[5] = sum[5-5] + 1; + 1 because including N[j] coin makes the sum do the same for remaining sums. can be represented mathematically like this *C*(*N*,*m*) = *C*(*N*,*m* - 1) + *C*(*N* - *S**m*,*m*) Or This is the least I can say. M(j) = Minimum number of coins required to make change for amount of money j. M(j) = Min { M( j - vi ) } + 1; i complexity O(n^S) for the Sum S. - Azhar. - Azhar. On Tue, Jul 5, 2011 at 4:37 PM, Dumanshu duman...@gmail.com wrote: @Azhar: could u plz explain the q8. problem. On Jul 5, 12:13 pm, Azhar Hussain azhar...@gmail.com wrote: Q8 is a DP problem, here is the solution #include stdio.h #define MAX 125 #define VAL 6 int Min[MAX]; int N[VAL] = {5, 10, 20, 25, 50, 100}; int main(void) { int i, j; for (i = 1; i MAX; i++) Min[i] = 100; for (i = 5; i MAX; i += 5) for (j = 0; j VAL; j++) if ((N[j] = i) ((Min[i-N[j]] + 1) Min[i])) Min[i] = Min[i-N[j]] + 1; fprintf(stderr, \n***\n); for (i = 0; i MAX; i += 5) fprintf(stderr, %d = %d\n, i, Min[i]); return 0; } OUTPUT: *** 0 = 0 5 = 1 10 = 1 15 = 2 20 = 1 25 = 1 30 = 2 35 = 2 40 = 2 45 = 2 50 = 1 55 = 2 60 = 2 65 = 3 70 = 2 75 = 2 80 = 3 85 = 3 90 = 3 95 = 3 100 = 1 105 = 2 110 = 2 115 = 3 120 = 2 more information can be found athttp:// www.topcoder.com/tc?module=Staticd1=tutorialsd2=dynProg - Azhar. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Reason for banning
some new moderators are sanket, arpit, sunny, piyush On Wed, Jul 6, 2011 at 9:41 PM, Arpit Sood soodfi...@gmail.com wrote: it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Reason for banning
lol, arpit you have just joined, lol On Wed, Jul 6, 2011 at 9:44 PM, shady sinv...@gmail.com wrote: some new moderators are sanket, arpit, sunny, piyush On Wed, Jul 6, 2011 at 9:41 PM, Arpit Sood soodfi...@gmail.com wrote: it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Reversing the order of words in String
I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Puzzle
Let speed of boat be x miles/hr Let speed of river be s miles/hr First Method: Hat comes down 1 mile in 10 minutes. Hat comes with flow of river only. So its speed is equal to speed of river. In 60 minutes, it will travel 6 miles. thus, s = 6 miles/hr Second Method: Distance travelled upward by boat = 1 + (5/60)*(x-s) miles Distance travelled downward by boat = (5/60)*(x+s) miles Both are same, so 1 + (5/60)*(x-s) = (5/60)*(x+s) x gets cancelled, and we have s/6 = 1 s = 6 miles/hr Second method is just one possible method which nobody would like to follow. First one is easier and faster - win-win situation For a change the easier method is faster as well -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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.
[algogeeks] Re: Reason for banning
Arpit, is it possible to remove the ban from my other email id? I would like to use that email address for activities on this group... On Jul 6, 11:16 am, shady sinv...@gmail.com wrote: lol, arpit you have just joined, lol On Wed, Jul 6, 2011 at 9:44 PM, shady sinv...@gmail.com wrote: some new moderators are sanket, arpit, sunny, piyush On Wed, Jul 6, 2011 at 9:41 PM, Arpit Sood soodfi...@gmail.com wrote: it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reversing the order of words in String
good job but how can this be done in one traversal as asked on the Adobe Interview Questions threadhttps://groups.google.com/forum/#%21msg/algogeeks/oEL8z4wwMJY/FAVdr2McPqIJ . On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com wrote: I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reversing the order of words in String
I have proposed my solution in one of the previous posts.Check the solution there On Wed, Jul 6, 2011 at 10:10 PM, Tushar Bindal tushicom...@gmail.comwrote: good job but how can this be done in one traversal as asked on the Adobe Interview Questions threadhttps://groups.google.com/forum/#%21msg/algogeeks/oEL8z4wwMJY/FAVdr2McPqIJ . On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.comwrote: I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Help!!
Hey anyone Pl help... its clearly written code and algo u know vry well so it wont take much time :) On Jul 5, 8:43 pm, KK kunalkapadi...@gmail.com wrote: This is the solution to the MST problem m getting WA again n again... cant figure out where's the mistake... so plzzz help!!!https://www.spoj.pl/problems/BLINNET/ #includeiostream #includestring #includevector #includelist #includequeue #define MAXINT (int)9e9 #define TR(a,it) for(typeof((a).begin()) it=(a).begin(); it! =(a).end(); ++it) using namespace std; struct node { long int data; string name; long int cost; long int distance; long int parent; friend bool operator(const node a, const node b); }; long int prims(vector listnode adjlist, int n); int main() { freopen(input.txt, r, stdin); freopen(output.txt, w, stdout); long int n, t, no_neigh; cin t; while(t--) { vector listnode adjlist; node temp; getchar(); cin n; adjlist.resize(n + 1); for(int i=1; i=n; i++) { cin temp.name; //temp.data = i; //adjlist[i].push_back(temp); cin no_neigh; for(int j=1; j=no_neigh; j++) { cin temp.data temp.cost; adjlist[i].push_back(temp); } } /*for(int i=1; i=n; i++) { cout i : endl; TR(adjlist[i], it) cout it-data it-cost endl; }*/ cout prims(adjlist, n) endl; } } bool operator(const node a, const node b) { return a.distance b.distance; } long int prims(vector listnode adjlist, int n) { priority_queuenode, vectornode, greaternode pq; node heap[n+1]; for(long int i=1; i=n; i++) { heap[i].data = i; heap[i].distance = MAXINT; heap[i].parent = -1; } long int start = 1; heap[start].distance = 0; pq.push(heap[start]); while(!pq.empty()) { node top = pq.top(); pq.pop(); //cout popped : top.data endl; if(top.distance = heap[top.data].distance) { //cout Traversed endl; TR(adjlist[top.data], it) { if(heap[it-data].distance it-cost) { heap[it-data].distance = it-cost; heap[it-data].parent = top.data; //cout Pushed it-data endl; pq.push(heap[it-data]); } } } } long int sum = 0; for(int i=1; i=n; i++) sum += heap[i].distance; return sum; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reversing the order of words in String
Saurabh, I understood your solution but wonder if it is purely single traversal In affect, you have a second traversal when you are popping the strings from stack to form the reverse order string. Though the second activity is less than O(n) i.e. O(#words in string) Nice solution, this way we can also get rid of extra spaces easily in the actual string if that is also to be done. On Wed, Jul 6, 2011 at 10:16 PM, saurabh singh saurab...@gmail.com wrote: I have proposed my solution in one of the previous posts.Check the solution there On Wed, Jul 6, 2011 at 10:10 PM, Tushar Bindal tushicom...@gmail.com wrote: good job but how can this be done in one traversal as asked on the Adobe Interview Questions thread. On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com wrote: I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] puzzle
* You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Some adobe interview questions.
On Jul 5, 4:04 am, Dumanshu duman...@gmail.com wrote: ans1. use counting sort for character array (0 to 255) then check for the second string if same or not. ans2. send 1 and 2, 1 comes back, send 10 and 5, 2 comes back, send 2 and 1 ans3. As vikas said, sum of digits should b 8. In that case the number must have a zero digit because 1st digit the no. of zeroes can't be zero then. right? print all the combinations. need help on this. ans4. a function with string, first index, last index as arguments and return true or false. increment first index and decrement last index for recursive call. ans5. I have no idea. may b we can take help of shunting algorithm. but there ought to be an easier way to do this. Do we have to WAP a general one for these expressions??? ans6. allocate same number of bytes for the reversed string. now traverse the original string from the back. as soon as u encounter a space say at position x or you come to 0 index, call the current = function (x+1,current) or current = function(0,current). this function copies the original string from position x+1 to (while(space or null)) in reversed string at position current and returns current + no. of characters copied. ans8. somebody plz explain this. do we have to find the values for a,b,c,d,e,f so that we can get return change for 100,50,25,10,5? 10, 5,5,20,25,50... how to get change for 5 then? ans9. lets say we have to allocate 100*200 i.e. rows 100 and columns 200 int **a = (int **)malloc(sizeof(int *)*100); a[0] = (int *)malloc(sizeof(int)*100*200); for(i=1;i100;i++) a[i] = (a[i-1]+200); I think this will be better approach: Let's say the array is 100*100 int (*a)[100]; a = (int (*)[100])malloc(sizeof(int)*100*100); ans10. use hashtables, first traversal get true for all values present. then second traversal, check if (X- arr[i]) is present in hashtable, if yes print. Here I see one problem in it, if the numbers are negative then we cannot hash into directly, we need a modified hash function in this case.here we will have to add maximum negative number(in magnitude) to X-arr[i]. ans11. i think ans to this one is 1 byte. because some information is stored.. may be. m nt sure :P ans12. typedef struct node * NODE; NODE sortlist(NODE head,int n) { if(n==1) return head; if(!n) return null; NODE temp =head; for(int i=0;in\2;i++)temp=temp-next; return merge(sortlist(head,n/2),sortlist(temp,n/2 + (n%2));); } NODE merge(NODE t1,NODE t2) { NODE head=NULL,temp=NULL; int set =0; while(t1 t2) { if(t1-data t2-data) { if(!set){head=t1;temp = head;set=1;t1=t1-next;} else { temp-next = t1; t1=t1-next;} } else { if(!set){head=t2;temp = head;set=1;t2=t2-next;} else { temp-next = t2; t2=t2-next; } } while(t1) { temp-next = t1; t1 = t1-next;} while(t2) { temp-next = t2; t2 = t2-next;} temp-next = NULL; return head; } did i miss any case? On Jul 5, 11:24 am, vikas mehta...@gmail.com wrote: These all were asked cumulatively in five interviews, one after another. Q1 given 2 string A ,B. write a code to find all character of A exists in B or not? Q2. A puzzle athttp://mathforum.org/library/drmath/view/56756.html Q3. Find a 8-digit number, where the first figure defines the count of zeros in this number, the second figure the count of numeral 1 in this number and so on Q4. write a recursive function to find a given string is palindrome or not? Q5. write a code to generate the parse tree like compilers do internally for any given expression e.g. a+(b+c*(e/f)+d)*g Q6. 3 reverse the string word by word e.g. My name is pradeep .. o/p shd be pradeep is name My ...intwer expecting a 1 traversal algo Q7. C++ (What are virtual functions) what happened if I do Base *d = new Derived(); and Derived *d = new Base(); is it error(in which statement) or not if yes what type of error? Q8. you have 6 coins of Indian denomination (a+b+c+d+e+f=115 paisa) ...if user ask for a change of 100,50,25,10,5 paisa then you r not able to give find the value of a,b,c,d,e,f.e.g. lets if user ask for a change of 25 paisa then you r not able to return (10+10+5) or (20+5) Q9. allocate 2D array dynamically with min no. of malloc calls. Q10. given unsorted array and a no. X ,find 2 no. whose sum is Xa[i]+a[j]=X ...do it in O(n) Q11. class A {}; A obj ; what is sizeof(obj)explain ANS Q12. Write a code of Merge sort on Linked list. Lets discuss them -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] NVIDIA Q
@ashish Most probably because empty struct in C have nothing associated with it. They are as good as nothing. But empty classes in C++ can have member functions. These functions need to be associated with object, having a unique address, for that class. And unique address is not possible with class of size 0 as already explained above. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/XP8yGGz2YbEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Reversing the order of words in String
I read that solution. But the same doubt as Navneet which I think you also raised i one of your posts on that thread On Wed, Jul 6, 2011 at 10:34 PM, Navneet Gupta navneetn...@gmail.comwrote: Saurabh, I understood your solution but wonder if it is purely single traversal In affect, you have a second traversal when you are popping the strings from stack to form the reverse order string. Though the second activity is less than O(n) i.e. O(#words in string) Nice solution, this way we can also get rid of extra spaces easily in the actual string if that is also to be done. On Wed, Jul 6, 2011 at 10:16 PM, saurabh singh saurab...@gmail.com wrote: I have proposed my solution in one of the previous posts.Check the solution there On Wed, Jul 6, 2011 at 10:10 PM, Tushar Bindal tushicom...@gmail.com wrote: good job but how can this be done in one traversal as asked on the Adobe Interview Questions thread. On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com wrote: I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] puzzle
i think this puzzle follows arithmetic progression...i'm not sure though...does anybody have a clean explanation for this? On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan narayan.shiv...@gmail.comwrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
100th floor is the answer On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan narayan.shiv...@gmail.comwrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] puzzle
Eggs can never break the building. So dropping the eggs won't break the building - whether you drop them from 1st floor or 100th floor. On Wed, Jul 6, 2011 at 10:42 PM, Sriganesh Krishnan 2448...@gmail.comwrote: i think this puzzle follows arithmetic progression...i'm not sure though...does anybody have a clean explanation for this? On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan narayan.shiv...@gmail.comwrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] NVIDIA Q
@piyush: No,one can declare the variable of empty struct and access its address via pointer. So, when you are accessing address via pointer means some memory is allocated for that variable. But *sizeof()* operator returns *zero*?? why??? On Wed, Jul 6, 2011 at 10:38 PM, T3rminal piyush@gmail.com wrote: @ashish Most probably because empty struct in C have nothing associated with it. They are as good as nothing. But empty classes in C++ can have member functions. These functions need to be associated with object, having a unique address, for that class. And unique address is not possible with class of size 0 as already explained above. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/XP8yGGz2YbEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
14 attempts Aseem On Wed, Jul 6, 2011 at 10:44 PM, Tushar Bindal tushicom...@gmail.comwrote: Eggs can never break the building. So dropping the eggs won't break the building - whether you drop them from 1st floor or 100th floor. On Wed, Jul 6, 2011 at 10:42 PM, Sriganesh Krishnan 2448...@gmail.comwrote: i think this puzzle follows arithmetic progression...i'm not sure though...does anybody have a clean explanation for this? On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan narayan.shiv...@gmail.comwrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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.
[algogeeks] Re: Some adobe interview questions.
For Q1: if length1!=length2 = false else take 2 arrays ch1[256] and ch2[256] For every character c in each string increment the element ch[c] in the respective array; now traverse both arrays together. if each ch1[] element =each ch2[] element = true else =false __ Ankit Chaudhary Computer Engineering Netaji Subhas Institute of Technology On Jul 6, 3:50 pm, Abhi abhi123khat...@gmail.com wrote: Q1.First sort both the strings using counting sort perhaps. Then starting from the first character, search for it in the second string using binary search.The succeeding character of A will be searched from the index in B at which last character of A was found Worst case: When both the strings are alike : O(log(m) + log(m-1) + log(m-2) ...log(1)) = O(m*log(m)) But Average case will be quite efficient Abhishek Khattri, Computer Engineering, Netaji Subhas Institute of Technology -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
Just to let you guys know it's a good legitimate problem with no trick answer. People who don't know the solution should try. On Wed, Jul 6, 2011 at 10:44 PM, Tushar Bindal tushicom...@gmail.com wrote: Eggs can never break the building. So dropping the eggs won't break the building - whether you drop them from 1st floor or 100th floor. On Wed, Jul 6, 2011 at 10:42 PM, Sriganesh Krishnan 2448...@gmail.com wrote: i think this puzzle follows arithmetic progression...i'm not sure though...does anybody have a clean explanation for this? On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Reason for banning
he made me as well as you moderator just now. what is your banned id ? I don't think any of your ids is banned now On Wed, Jul 6, 2011 at 10:04 PM, Sanket sanku.v...@gmail.com wrote: Arpit, is it possible to remove the ban from my other email id? I would like to use that email address for activities on this group... On Jul 6, 11:16 am, shady sinv...@gmail.com wrote: lol, arpit you have just joined, lol On Wed, Jul 6, 2011 at 9:44 PM, shady sinv...@gmail.com wrote: some new moderators are sanket, arpit, sunny, piyush On Wed, Jul 6, 2011 at 9:41 PM, Arpit Sood soodfi...@gmail.com wrote: it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Reason for banning
none of ur ids are banned On Wed, Jul 6, 2011 at 10:55 PM, Arpit Sood soodfi...@gmail.com wrote: he made me as well as you moderator just now. what is your banned id ? I don't think any of your ids is banned now On Wed, Jul 6, 2011 at 10:04 PM, Sanket sanku.v...@gmail.com wrote: Arpit, is it possible to remove the ban from my other email id? I would like to use that email address for activities on this group... On Jul 6, 11:16 am, shady sinv...@gmail.com wrote: lol, arpit you have just joined, lol On Wed, Jul 6, 2011 at 9:44 PM, shady sinv...@gmail.com wrote: some new moderators are sanket, arpit, sunny, piyush On Wed, Jul 6, 2011 at 9:41 PM, Arpit Sood soodfi...@gmail.com wrote: it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com . To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
Re: [algogeeks] puzzle
@Navneet Didn't get your point -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] puzzle
14 On 6 Jul 2011 22:35, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
@tiru and @aseem: explanation pls...! On Wed, Jul 6, 2011 at 11:11 PM, TIRU REDDY tiru...@gmail.com wrote: 14 On 6 Jul 2011 22:35, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
s(s+1)/2 must be close to 100. The best possible number is 14. try from 14th floor. next from 14+13th floor. next from 14+13+12th floor. Worest case number of attempts = 14. Best Regards, T V Thirumala Reddy Engineer, Qualcomm India Private Ltd. 1540C30, 15th Floor, Building #9, Mindspace, Hitech city, Madhapur, Hyderabad-81. On Wed, Jul 6, 2011 at 11:14 PM, Sriganesh Krishnan 2448...@gmail.comwrote: @tiru and @aseem: explanation pls...! On Wed, Jul 6, 2011 at 11:11 PM, TIRU REDDY tiru...@gmail.com wrote: 14 On 6 Jul 2011 22:35, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Random Number Generator
Describe an implementation of Random(a, b) that only make calls to Random(0, 1)? Well I am thinking this way: - Divide the range (a,b) in to 2 parts like (a, mid) and (mid, b) where mid = (a+b)/2 - Select one of the range using a call to Random(0, 1). - Then continue dividing the new range and selecting a new based on a call to Random(0, 1) until we have two elements left. - From the two elements one can easily be selected by a call to Random(a, b). Is this approach correct? Or something else can be done? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/kCRJ22w0_wMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] puzzle
Suppose u start from x floor. Two cases arise...the egg breaks or it does not. If it doesthen u have to move linearly from first floor. till x-1 floor..Max attempts reqd. = x If it does not break.take a jump of x-1 because ur number of attempts has already increased by1. .Max. attempts reqd. =x . . . . . . . so taking jumps u have. 1+2+...x-1 + x=100 or x(x+1)/2 100 now find min value of x. Aseem On Wed, Jul 6, 2011 at 11:18 PM, TIRU REDDY tiru...@gmail.com wrote: s(s+1)/2 must be close to 100. The best possible number is 14. try from 14th floor. next from 14+13th floor. next from 14+13+12th floor. Worest case number of attempts = 14. Best Regards, T V Thirumala Reddy Engineer, Qualcomm India Private Ltd. 1540C30, 15th Floor, Building #9, Mindspace, Hitech city, Madhapur, Hyderabad-81. On Wed, Jul 6, 2011 at 11:14 PM, Sriganesh Krishnan 2448...@gmail.comwrote: @tiru and @aseem: explanation pls...! On Wed, Jul 6, 2011 at 11:11 PM, TIRU REDDY tiru...@gmail.com wrote: 14 On 6 Jul 2011 22:35, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Random Number Generator
how about a*rand(0,1)+b? On Wed, Jul 6, 2011 at 11:20 PM, Nitish Garg nitishgarg1...@gmail.comwrote: implementation of Random(a, b) that only make calls to Random(0, 1) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: puzzle
whr s(S+1)/2 must be nearly equal to 100 can uexplain.. On Jul 6, 10:48 pm, TIRU REDDY tiru...@gmail.com wrote: s(s+1)/2 must be close to 100. The best possible number is 14. try from 14th floor. next from 14+13th floor. next from 14+13+12th floor. Worest case number of attempts = 14. Best Regards, T V Thirumala Reddy Engineer, Qualcomm India Private Ltd. 1540C30, 15th Floor, Building #9, Mindspace, Hitech city, Madhapur, Hyderabad-81. On Wed, Jul 6, 2011 at 11:14 PM, Sriganesh Krishnan 2448...@gmail.comwrote: @tiru and @aseem: explanation pls...! On Wed, Jul 6, 2011 at 11:11 PM, TIRU REDDY tiru...@gmail.com wrote: 14 On 6 Jul 2011 22:35, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Random Number Generator
Don't think this will work. Try rand(4, 7) : 4*rand(0,1) + 7 = 4*0 + 7 = 7 or 4*1 + 7 = 11(out of scope). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/tJ40--FYSeoJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Random Number Generator
For RNG in range [a,b] first thing is that all numbers should be generated with equal probability. in your case you are considering mid in both the ranges so you can modify it like [a,mid],[mid+1,b] still I think this will work fine as far as the ranges get divided equally.. like consider the case [3,5] so division will be [3,4],[5] still probabilities will not be equal. so answer should be make b-a calls to rand(0,1) and return a+sum of return values of all the calls On Wed, Jul 6, 2011 at 11:20 PM, Nitish Garg nitishgarg1...@gmail.comwrote: Describe an implementation of Random(a, b) that only make calls to Random(0, 1)? Well I am thinking this way: - Divide the range (a,b) in to 2 parts like (a, mid) and (mid, b) where mid = (a+b)/2 - Select one of the range using a call to Random(0, 1). - Then continue dividing the new range and selecting a new based on a call to Random(0, 1) until we have two elements left. - From the two elements one can easily be selected by a call to Random(a, b). Is this approach correct? Or something else can be done? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/kCRJ22w0_wMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Puzzle
speed of river=(distance traveled by object in it) / total time it took to travel here hat has traveled a distance of 1 KM and it has taken =5mn+5 min=10 min=10min/60=1/6 hrs; so speed = 1/(1/6)=6km/hr On Jul 6, 9:28 pm, Tushar Bindal tushicom...@gmail.com wrote: Let speed of boat be x miles/hr Let speed of river be s miles/hr First Method: Hat comes down 1 mile in 10 minutes. Hat comes with flow of river only. So its speed is equal to speed of river. In 60 minutes, it will travel 6 miles. thus, s = 6 miles/hr Second Method: Distance travelled upward by boat = 1 + (5/60)*(x-s) miles Distance travelled downward by boat = (5/60)*(x+s) miles Both are same, so 1 + (5/60)*(x-s) = (5/60)*(x+s) x gets cancelled, and we have s/6 = 1 s = 6 miles/hr Second method is just one possible method which nobody would like to follow. First one is easier and faster - win-win situation For a change the easier method is faster as well -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website:www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Random Number Generator
Oops ... my method will also not work as probabilities will not be equal !!! On Wed, Jul 6, 2011 at 11:29 PM, sunny agrawal sunny816.i...@gmail.comwrote: For RNG in range [a,b] first thing is that all numbers should be generated with equal probability. in your case you are considering mid in both the ranges so you can modify it like [a,mid],[mid+1,b] still I think this will work fine as far as the ranges get divided equally.. like consider the case [3,5] so division will be [3,4],[5] still probabilities will not be equal. so answer should be make b-a calls to rand(0,1) and return a+sum of return values of all the calls On Wed, Jul 6, 2011 at 11:20 PM, Nitish Garg nitishgarg1...@gmail.comwrote: Describe an implementation of Random(a, b) that only make calls to Random(0, 1)? Well I am thinking this way: - Divide the range (a,b) in to 2 parts like (a, mid) and (mid, b) where mid = (a+b)/2 - Select one of the range using a call to Random(0, 1). - Then continue dividing the new range and selecting a new based on a call to Random(0, 1) until we have two elements left. - From the two elements one can easily be selected by a call to Random(a, b). Is this approach correct? Or something else can be done? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/kCRJ22w0_wMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: puzzle
the solution is given herehttp://www.thecareerplus.com/?page=resourcescat=150subCat=10qNo=2 but can anyone lease explain it better please give a original solution and stop making rude comments about answers posted genuinely. If you have an original solution, please post it. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Random Number Generator
Yes, I meant (a, mid) and (mid+1, b) only. It now looks to me as the method I proposed will work well if the numbers in the range are a power of 2, in which case the division will be ideal. Still looking a solution for any general range. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/s8InuwZYlOsJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Interview Question
If you allow for the following assumptions: 1. All numbers fit into a 32 bit or 64 bit integer. 2. The arrays are actually linked lists. Time complexity: O(N) Space complexity: O(1) Solution: 1. Apply radix sort. (binary radix sort would probably do fine) Note: You can make the sort stable only because of the linked lists (can't be done in a simple array). This is the reason for the 2 assumptions. Complexiy: O(N K). Space: 2 extra pointers = O(1). 2. Find mismatches between the 2 sorted sequences. O(N) The 2nd assumption sort-of cheats because it implicitly requires O(N) extra space in the pointers of the linked list. -- DK http://twitter.com/divyekapoor http://www.divye.in -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/vgEeAQHJN08J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: NVIDIA Q
hey i am getting size of empty struct 1. check my code #includeiostream #includeconio.h using namespace std; struct empty{}; int main() { empty e; int x=sizeof(e); coutx; getch(); return 0; } when i run this i get 1 as output On Jul 6, 10:16 pm, Ashish Modi ashishrmod...@gmail.com wrote: @piyush: No,one can declare the variable of empty struct and access its address via pointer. So, when you are accessing address via pointer means some memory is allocated for that variable. But *sizeof()* operator returns *zero*?? why??? On Wed, Jul 6, 2011 at 10:38 PM, T3rminal piyush@gmail.com wrote: @ashish Most probably because empty struct in C have nothing associated with it. They are as good as nothing. But empty classes in C++ can have member functions. These functions need to be associated with object, having a unique address, for that class. And unique address is not possible with class of size 0 as already explained above. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/XP8yGGz2YbEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Random Number Generator
i think a+rand(0,1)(b-a) will work -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Random Number Generator
You can try Random(a,b)=(b-a)*Random(0,1)+a Thanks and Regards DEVANSH GUPTA MNNIT, ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: NVIDIA Q
Run dis in saving the same in .C format m getting 0...:) #includestdio.h #includeconio.h struct empty{}; int main() { struct empty e; int x=sizeof(e); printf(%d,x); getch(); return 0; } On Wed, Jul 6, 2011 at 11:58 PM, shiv narayan narayan.shiv...@gmail.comwrote: hey i am getting size of empty struct 1. check my code #includeiostream #includeconio.h using namespace std; struct empty{}; int main() { empty e; int x=sizeof(e); coutx; getch(); return 0; } when i run this i get 1 as output On Jul 6, 10:16 pm, Ashish Modi ashishrmod...@gmail.com wrote: @piyush: No,one can declare the variable of empty struct and access its address via pointer. So, when you are accessing address via pointer means some memory is allocated for that variable. But *sizeof()* operator returns *zero*?? why??? On Wed, Jul 6, 2011 at 10:38 PM, T3rminal piyush@gmail.com wrote: @ashish Most probably because empty struct in C have nothing associated with it. They are as good as nothing. But empty classes in C++ can have member functions. These functions need to be associated with object, having a unique address, for that class. And unique address is not possible with class of size 0 as already explained above. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/XP8yGGz2YbEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sanchit Mittal Second Year Undergraduate Computer Engineering Delhi College of Engineering ph- +919582414494 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: NVIDIA Q
while runnin same code in .cpp format gives 1 On Thu, Jul 7, 2011 at 12:19 AM, sanchit mittal sm14it...@gmail.com wrote: Run dis in saving the same in .C format m getting 0...:) #includestdio.h #includeconio.h struct empty{}; int main() { struct empty e; int x=sizeof(e); printf(%d,x); getch(); return 0; } On Wed, Jul 6, 2011 at 11:58 PM, shiv narayan narayan.shiv...@gmail.comwrote: hey i am getting size of empty struct 1. check my code #includeiostream #includeconio.h using namespace std; struct empty{}; int main() { empty e; int x=sizeof(e); coutx; getch(); return 0; } when i run this i get 1 as output On Jul 6, 10:16 pm, Ashish Modi ashishrmod...@gmail.com wrote: @piyush: No,one can declare the variable of empty struct and access its address via pointer. So, when you are accessing address via pointer means some memory is allocated for that variable. But *sizeof()* operator returns *zero*?? why??? On Wed, Jul 6, 2011 at 10:38 PM, T3rminal piyush@gmail.com wrote: @ashish Most probably because empty struct in C have nothing associated with it. They are as good as nothing. But empty classes in C++ can have member functions. These functions need to be associated with object, having a unique address, for that class. And unique address is not possible with class of size 0 as already explained above. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/XP8yGGz2YbEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sanchit Mittal Second Year Undergraduate Computer Engineering Delhi College of Engineering ph- +919582414494 -- Sanchit Mittal Second Year Undergraduate Computer Engineering Delhi College of Engineering ph- +919582414494 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Random Number Generator
If I understood you properly, Random(a,b)=(b-a)*Random(0,1)+a -Random(3, 6) = (3)*Random(0, 1) + 3 = 3 + 3 = 6 or 0 + 3 = 3 Just generates 3 and 6 with equal probability, what about 4 and 5? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/I5enuEx37eQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: puzzle
Approach 1: Start from storey 1 and go up. keep dropping one of the eggs. As soon at it breaks, return the storey you are in now. No. of drops in the worst case: 99 Approach 2: Split the building into 10 '10 storeyed' parts. Start Dropping eggs at 10,20,30,...th storey. If it breaks at say 40th, use the other egg from 31st storey till 39th and return the ans. No. of drops in worst case: approx. 20 Approach 3: Why should v divide the building into equal storeyed segments? Have more storeys in lower part of the building and let it come down as we go up. How does it help? Well by the nature of our method, if it breaks at some 80+ storey (say), we want use the second egg lesser number of times that it was when it is in 20th storey or something. The first egg can be used in this order: 14,27,39,50,60... ( I am about to sleep now and I have no energy to find out the exact starting number. But I hope that u get the idea.) Now the same approach can be used once the first egg breaks. No. of drops in worst case: Approx. 14 More on this problem: Find an algo for any general number of eggs and any general number storeys... Dont look at the hint below before giving it a try. Hint: DP On Jul 6, 10:05 pm, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Random Number Generator
@Nitish: I'm assuming that Random(0,1) returns 0 and 1 randomly, with equal probability. Let n = ceiling(log_2(b-a+1)). Use the rejection method (http://en.wikipedia.org/wiki/ Rejection_sampling) as follows: Generate an integer, k, 0 = k 2^n, one bit at a time, using Random(0,1) n times. k will be uniformly distributed between 0 and 2^n - 1. If k b-a, reject k and generate a new one. Otherwise, return k+a. The algorithm terminates with probability 1 with an expected number of calls to Random(0,1) of n * 2^n / (b - a + 1). Dave On Jul 6, 12:50 pm, Nitish Garg nitishgarg1...@gmail.com wrote: Describe an implementation of Random(a, b) that only make calls to Random(0, 1)? Well I am thinking this way: - Divide the range (a,b) in to 2 parts like (a, mid) and (mid, b) where mid = (a+b)/2 - Select one of the range using a call to Random(0, 1). - Then continue dividing the new range and selecting a new based on a call to Random(0, 1) until we have two elements left. - From the two elements one can easily be selected by a call to Random(a, b). Is this approach correct? Or something else can be done? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Random Number Generator
@nitish i think all above meant 3+rand(0,1)+rand(0,1)+rand(0,1) surender On Thu, Jul 7, 2011 at 12:36 AM, Nitish Garg nitishgarg1...@gmail.comwrote: If I understood you properly, Random(a,b)=(b-a)*Random(0,1)+**a -Random(3, 6) = (3)*Random(0, 1) + 3 = 3 + 3 = 6 or 0 + 3 = 3 Just generates 3 and 6 with equal probability, what about 4 and 5? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/I5enuEx37eQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Reason for banning
I am able to access the posts using my other email Id, thanks for the help. On Jul 6, 12:37 pm, shady sinv...@gmail.com wrote: none of ur ids are banned On Wed, Jul 6, 2011 at 10:55 PM, Arpit Sood soodfi...@gmail.com wrote: he made me as well as you moderator just now. what is your banned id ? I don't think any of your ids is banned now On Wed, Jul 6, 2011 at 10:04 PM, Sanket sanku.v...@gmail.com wrote: Arpit, is it possible to remove the ban from my other email id? I would like to use that email address for activities on this group... On Jul 6, 11:16 am, shady sinv...@gmail.com wrote: lol, arpit you have just joined, lol On Wed, Jul 6, 2011 at 9:44 PM, shady sinv...@gmail.com wrote: some new moderators are sanket, arpit, sunny, piyush On Wed, Jul 6, 2011 at 9:41 PM, Arpit Sood soodfi...@gmail.com wrote: it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com . To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hidequoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to
[algogeeks] Re: Some adobe interview questions.
for Q5 change the expr into postfix and then build expression tree... but is expression tree same as parse tree?? correct me if i m wrong!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] DP or DFS
https://www.spoj.pl/problems/SHOP/ Anybody plzz post a solution to the above problem... i tried with dp but it failed... How to implement with DFS or if possible with DP??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] DP or DFS
nothing :P BFS :P On Wed, Jul 6, 2011 at 1:23 PM, KK kunalkapadi...@gmail.com wrote: https://www.spoj.pl/problems/SHOP/ Anybody plzz post a solution to the above problem... i tried with dp but it failed... How to implement with DFS or if possible with DP??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Reversing the order of words in String
Can we do it using linked list if ONE TIME TRAVERSAL is a constraint?? On 7/6/11, Tushar Bindal tushicom...@gmail.com wrote: I read that solution. But the same doubt as Navneet which I think you also raised i one of your posts on that thread On Wed, Jul 6, 2011 at 10:34 PM, Navneet Gupta navneetn...@gmail.comwrote: Saurabh, I understood your solution but wonder if it is purely single traversal In affect, you have a second traversal when you are popping the strings from stack to form the reverse order string. Though the second activity is less than O(n) i.e. O(#words in string) Nice solution, this way we can also get rid of extra spaces easily in the actual string if that is also to be done. On Wed, Jul 6, 2011 at 10:16 PM, saurabh singh saurab...@gmail.com wrote: I have proposed my solution in one of the previous posts.Check the solution there On Wed, Jul 6, 2011 at 10:10 PM, Tushar Bindal tushicom...@gmail.com wrote: good job but how can this be done in one traversal as asked on the Adobe Interview Questions thread. On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com wrote: I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message
Re: [algogeeks] Unique substring
I think this problem can be solved by KMP algorithm in O(n) time. I find suffix tree hard to implement. On Tue, Jul 5, 2011 at 9:43 PM, Aakash Johari aakashj@gmail.com wrote: Its probably Longest repeating substring problem. So it can be solved with suffix array/tree easily in O(n) time. On Tue, Jul 5, 2011 at 9:07 AM, Akshata Sharma akshatasharm...@gmail.comwrote: @aakash: see this. I came across this question here http://geeksforgeeks.org/forum/topic/largest-unique-substring-from-a-string-google On Tue, Jul 5, 2011 at 3:15 PM, Aakash Johari aakashj@gmail.comwrote: Please make problem clear with example. Longest unique substring is the string itself, or i have misunderstood the problem. On Mon, Jul 4, 2011 at 11:53 PM, Navneet Gupta navneetn...@gmail.comwrote: I think you guys are on different page. There is a difference between substring and subsequence. http://en.wikipedia.org/wiki/Subsequence#Substring_vs._subsequence This question asks what is the longest SUBSTRING which is unique (there could also be none or multiple if lengths are equal) ^Thinking about solution. On Tue, Jul 5, 2011 at 12:20 PM, Azhar Hussain azhar...@gmail.com wrote: This link can be useful. http://geeksforgeeks.org/?p=12998 - Azhar. On Tue, Jul 5, 2011 at 11:31 AM, Akshata Sharma akshatasharm...@gmail.com wrote: someone please suggest me an efficient way to find the longest unique substring in a given string.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -Aakash Johari (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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -Aakash Johari (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. -- Hemesh singh -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Reason for banning
i have made you moderator sanket, you can even ban me now. :D On Thu, Jul 7, 2011 at 1:20 AM, Sanket sanku.v...@gmail.com wrote: I am able to access the posts using my other email Id, thanks for the help. On Jul 6, 12:37 pm, shady sinv...@gmail.com wrote: none of ur ids are banned On Wed, Jul 6, 2011 at 10:55 PM, Arpit Sood soodfi...@gmail.com wrote: he made me as well as you moderator just now. what is your banned id ? I don't think any of your ids is banned now On Wed, Jul 6, 2011 at 10:04 PM, Sanket sanku.v...@gmail.com wrote: Arpit, is it possible to remove the ban from my other email id? I would like to use that email address for activities on this group... On Jul 6, 11:16 am, shady sinv...@gmail.com wrote: lol, arpit you have just joined, lol On Wed, Jul 6, 2011 at 9:44 PM, shady sinv...@gmail.com wrote: some new moderators are sanket, arpit, sunny, piyush On Wed, Jul 6, 2011 at 9:41 PM, Arpit Sood soodfi...@gmail.com wrote: it is fine... :) in case of any complaint, suggestion please mail me i am one of the moderator... and one request from my side please don't discuss errors in code, like why is it giving WA, SIGSEV etc. concentrate on algorithms :D and Advertising, Spamming, Off-Topic posts will lead to banning of the member Happy coding Shady On Wed, Jul 6, 2011 at 9:11 PM, Sanket sanku.v...@gmail.com wrote: Thanks for the reply Shady. I was hoping that the moderator who banned me gets a chance to reply since I am pretty sure I have done neither of these knowingly - advertising kind of mails, or abusive mails, spamming. The only way this might have happened is if my account got hacked so if that was the case, I would like to know in order to take preventive actions and the only way to confirm this is by knowing what caused the ban. On Jul 6, 12:04 am, shady sinv...@gmail.com wrote: only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. I hope I get a reply to this instead of this ID also getting banned oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket sanku.v...@gmail.com wrote: Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com . To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hidequotedtext - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com . To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Arpit Sood -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at
Re: [algogeeks] Re: puzzle
And what about binary search? On Wed, Jul 6, 2011 at 12:26 PM, 991 guruprakash...@gmail.com wrote: Sorry abt the previous post ( and this one ) if it ended up as a spam. I just saw the question and left the place. When I finished posting, ppl hav already given replies... On Jul 7, 12:12 am, 991 guruprakash...@gmail.com wrote: Approach 1: Start from storey 1 and go up. keep dropping one of the eggs. As soon at it breaks, return the storey you are in now. No. of drops in the worst case: 99 Approach 2: Split the building into 10 '10 storeyed' parts. Start Dropping eggs at 10,20,30,...th storey. If it breaks at say 40th, use the other egg from 31st storey till 39th and return the ans. No. of drops in worst case: approx. 20 Approach 3: Why should v divide the building into equal storeyed segments? Have more storeys in lower part of the building and let it come down as we go up. How does it help? Well by the nature of our method, if it breaks at some 80+ storey (say), we want use the second egg lesser number of times that it was when it is in 20th storey or something. The first egg can be used in this order: 14,27,39,50,60... ( I am about to sleep now and I have no energy to find out the exact starting number. But I hope that u get the idea.) Now the same approach can be used once the first egg breaks. No. of drops in worst case: Approx. 14 More on this problem: Find an algo for any general number of eggs and any general number storeys... Dont look at the hint below before giving it a try. Hint: DP On Jul 6, 10:05 pm, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -Aakash Johari (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.
Re: [algogeeks] Reversing the order of words in String
@Piyush, could you elaborate your approach with Linked List? From what i am getting, even with Linked List, you would need two traversals at least. On Thu, Jul 7, 2011 at 2:07 AM, Piyush Sinha ecstasy.piy...@gmail.com wrote: Can we do it using linked list if ONE TIME TRAVERSAL is a constraint?? On 7/6/11, Tushar Bindal tushicom...@gmail.com wrote: I read that solution. But the same doubt as Navneet which I think you also raised i one of your posts on that thread On Wed, Jul 6, 2011 at 10:34 PM, Navneet Gupta navneetn...@gmail.comwrote: Saurabh, I understood your solution but wonder if it is purely single traversal In affect, you have a second traversal when you are popping the strings from stack to form the reverse order string. Though the second activity is less than O(n) i.e. O(#words in string) Nice solution, this way we can also get rid of extra spaces easily in the actual string if that is also to be done. On Wed, Jul 6, 2011 at 10:16 PM, saurabh singh saurab...@gmail.com wrote: I have proposed my solution in one of the previous posts.Check the solution there On Wed, Jul 6, 2011 at 10:10 PM, Tushar Bindal tushicom...@gmail.com wrote: good job but how can this be done in one traversal as asked on the Adobe Interview Questions thread. On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com wrote: I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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
Re: [algogeeks] Re: puzzle
We have two eggs,so have only two chances of missing.SO its about a combination of binary and linear search. On Thu, Jul 7, 2011 at 9:09 AM, Aakash Johari aakashj@gmail.com wrote: And what about binary search? On Wed, Jul 6, 2011 at 12:26 PM, 991 guruprakash...@gmail.com wrote: Sorry abt the previous post ( and this one ) if it ended up as a spam. I just saw the question and left the place. When I finished posting, ppl hav already given replies... On Jul 7, 12:12 am, 991 guruprakash...@gmail.com wrote: Approach 1: Start from storey 1 and go up. keep dropping one of the eggs. As soon at it breaks, return the storey you are in now. No. of drops in the worst case: 99 Approach 2: Split the building into 10 '10 storeyed' parts. Start Dropping eggs at 10,20,30,...th storey. If it breaks at say 40th, use the other egg from 31st storey till 39th and return the ans. No. of drops in worst case: approx. 20 Approach 3: Why should v divide the building into equal storeyed segments? Have more storeys in lower part of the building and let it come down as we go up. How does it help? Well by the nature of our method, if it breaks at some 80+ storey (say), we want use the second egg lesser number of times that it was when it is in 20th storey or something. The first egg can be used in this order: 14,27,39,50,60... ( I am about to sleep now and I have no energy to find out the exact starting number. But I hope that u get the idea.) Now the same approach can be used once the first egg breaks. No. of drops in worst case: Approx. 14 More on this problem: Find an algo for any general number of eggs and any general number storeys... Dont look at the hint below before giving it a try. Hint: DP On Jul 6, 10:05 pm, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -Aakash Johari (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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: puzzle
How AP(ans=14) solution is satisfying the constraints? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Some adobe interview questions.
Anyone for Q10, i wonder if it can really be solved in O(n). Very obvious O(nlogn) is what I know On Thu, Jul 7, 2011 at 1:25 AM, KK kunalkapadi...@gmail.com wrote: for Q5 change the expr into postfix and then build expression tree... but is expression tree same as parse tree?? correct me if i m wrong!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Random Number Generator
@surender Yep, I think the same. for(i=0;i(b-a);i++,a+=rand(0,1)); Watsay? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Reversing the order of words in String
If we only need to print the words in reverse order, strtok+recursion can help. Following is the code (which also stores the string into another string, not memory efficient though): #include stdio.h #include string.h #include stdlib.h char str[] = This is a new world; char sstr[sizeof(str)]; char *print_rev(char *tok) { char *nstr = NULL; if (tok) { nstr = strtok(NULL, ); print_rev(nstr); if (nstr) { // printf(%s , nstr); strcpy(sstr[strlen(sstr)], nstr); sstr[strlen(sstr)] = ' '; } } return nstr; } int main(int argc, char *argv[]) { char *nstr; printf(Org string -- %s\n, str); nstr = strtok(str, ); print_rev(str); strcpy(sstr[strlen(sstr)], nstr); printf(New string -- %s\n, sstr); return 0; } On Thu, Jul 7, 2011 at 9:10 AM, Navneet Gupta navneetn...@gmail.com wrote: @Piyush, could you elaborate your approach with Linked List? From what i am getting, even with Linked List, you would need two traversals at least. On Thu, Jul 7, 2011 at 2:07 AM, Piyush Sinha ecstasy.piy...@gmail.com wrote: Can we do it using linked list if ONE TIME TRAVERSAL is a constraint?? On 7/6/11, Tushar Bindal tushicom...@gmail.com wrote: I read that solution. But the same doubt as Navneet which I think you also raised i one of your posts on that thread On Wed, Jul 6, 2011 at 10:34 PM, Navneet Gupta navneetn...@gmail.comwrote: Saurabh, I understood your solution but wonder if it is purely single traversal In affect, you have a second traversal when you are popping the strings from stack to form the reverse order string. Though the second activity is less than O(n) i.e. O(#words in string) Nice solution, this way we can also get rid of extra spaces easily in the actual string if that is also to be done. On Wed, Jul 6, 2011 at 10:16 PM, saurabh singh saurab...@gmail.com wrote: I have proposed my solution in one of the previous posts.Check the solution there On Wed, Jul 6, 2011 at 10:10 PM, Tushar Bindal tushicom...@gmail.com wrote: good job but how can this be done in one traversal as asked on the Adobe Interview Questions thread. On Wed, Jul 6, 2011 at 9:49 PM, Navneet Gupta navneetn...@gmail.com wrote: I think somebody on this thread has asked this question but i am not able to find that. Question was if a string is like my name is ram, then output should be ram is name my. Wrote the code for same, so sharing. #includeiostream #includestring using namespace std; void SwapStringChars(string str, int pos1, int pos2) { char ch = str[pos1]; str[pos1] = str[pos2]; str[pos2] = ch; } void reverseString(string str, int left, int right) { for(int i = left ; i = left + (right-left)/2 ; i++) SwapStringChars(str, i, right + left -i)); } void reverseWordsInString(string str) { char space = ' '; int len = str.length(); int startIndex = 0, endIndex = 0; while(endIndex len - 1) { while(str[endIndex] != space endIndex len)endIndex++; reverseString(str, startIndex, endIndex-1); startIndex = endIndex; while(str[startIndex] == space)startIndex++; endIndex = startIndex; } } int main() { string str; cout\nEnter enter the string :; getline(cin,str); //Reverse whole string at once reverseString(str, 0, str.length() - 1); //Reverse Individual words in string reverseWordsInString(str); coutstr; cin.get(); return 0; } -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to
Re: [algogeeks] NVIDIA Q
Ok. So for differentiating objects, we have size 1. What will be size of following class:- class A{ int z; }; How does different objects gets differentiated in above case? On Wed, Jul 6, 2011 at 2:24 PM, durgaprasad k durga...@gmail.com wrote: The size will be 1 byte as there is nothing to look into the object. And it is 1 instead of zero because two objects of the class will have different addresses by assigning each object size 1. Regards, Durga On Wed, Jul 6, 2011 at 2:11 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: What is the size of an object of a class with no members in it?? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.