[algogeeks] Permutation Problem with repeating characters
Write a programme to produce all permutations of a given string where characters are not unique. That means you are not allowed to print the duplicate strings. Ex: If input is aaa The output should be only aaa -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Second shortest path
1. How to find second shortest path from a source to a target? (Modification of dijkstras algo to store second best in the node when the node is the target would suffice I think, But any other way?) 2. How to find the second best MST for a graph? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Query: Function returning void pointer
Can a function return a void pointer ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Amazon Onsite Chennai SDE
You are given a word and a dictionary. Now propose an algorithm edit the word (insert / delete characters) minimally to get a word that also exists in the dictionary. Cost of insertion and deletion is same. Write pseudocode for it. Seems like minimum edit distance problem but some modification is needed. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Amazon Onsite Chennai SDE
yeah, that is normal bryteforce. Any better idea? On 11/14/11, Ankur Garg ankurga...@gmail.com wrote: We can use a trie here .. Create a trie with all words of dictionary . Now delete the last character of the word and check if such a word is a valid word . If not see if adding a new character can make it a valid word . If not delete the next character and repeat the process again . This is what I can think of here. Any other solutions/guesses ? On Mon, Nov 14, 2011 at 12:43 PM, Aniket aniket...@gmail.com wrote: You are given a word and a dictionary. Now propose an algorithm edit the word (insert / delete characters) minimally to get a word that also exists in the dictionary. Cost of insertion and deletion is same. Write pseudocode for it. Seems like minimum edit distance problem but some modification is needed. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Amazon Onsite Chennai SDE
@Rajeev: The above algorithm assumes a source string and a destination string. But here you are provided only the source string. And you will have to edit it (minimally) such that the resulting string matches a word in the dictionary. Need slight modification. Looking for the modification. (Interviewer told. The same answer was given). On Mon, Nov 14, 2011 at 4:59 AM, rajeev bharshetty rajeevr...@gmail.comwrote: Levensteins algorithm On 14 Nov 2011 18:19, aniket chatterjee aniket...@gmail.com wrote: yeah, that is normal bryteforce. Any better idea? On 11/14/11, Ankur Garg ankurga...@gmail.com wrote: We can use a trie here .. Create a trie with all words of dictionary . Now delete the last character of the word and check if such a word is a valid word . If not see if adding a new character can make it a valid word . If not delete the next character and repeat the process again . This is what I can think of here. Any other solutions/guesses ? On Mon, Nov 14, 2011 at 12:43 PM, Aniket aniket...@gmail.com wrote: You are given a word and a dictionary. Now propose an algorithm edit the word (insert / delete characters) minimally to get a word that also exists in the dictionary. Cost of insertion and deletion is same. Write pseudocode for it. Seems like minimum edit distance problem but some modification is needed. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] BST question
As far as I understand, your solution will always contain the path that essentially start from root. But the actual problem states that the path may not necessarily start from root. On Fri, Nov 11, 2011 at 1:21 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: correct me if I am wrong #includestdio.h struct node { int data; struct node *left; struct node * right; }*root; int sum(int s,struct node *p,int ar[],int l) { if(p == NULL ) { return 0; } if(p-left == NULL p-right == NULL) { if( s - p-data == 0) { ar[l++] = p-data; int i; for( i = 0 ;i l ;i++) { printf(%d ,ar[i]); } printf(\n); } } ar[l++] = p-data; sum(s - p-data, p-left , ar , l); sum(s - p-data, p-right , ar, l); return 0; } struct node * getnode(int k) { struct node *temp = malloc(sizeof(struct node)); temp-data = k; temp-left= NULL; temp-right = NULL; return temp; } main() { int ar[50],value; root = getnode(5); root-left= getnode(2); root-right = getnode(2); root-left-left = getnode(7); root-left-right = getnode(8); root-right-left = getnode(3); root-right-right = getnode(7); value = 14; sum(value,root,ar,0); return 0; } On Fri, Nov 11, 2011 at 12:38 PM, aniket chatterjee aniket...@gmail.comwrote: Write a recursive function that will store each root to leaf path in an array. Now for each root to leaf path find the subarray which sums up to X. On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi All, Please give me the solution of this problem. A binary tree and a number X is given. Find all the paths(not necessarily starting from root) such that the sum equals X. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] BST question
And also your solution prints the root to leaf path that sums up to X. But the path may not contain root as well as leaf also. May be some intermediate 4 nodes (from root to leaf path)sums up to X. Your code doesnt provide the solution for that scenario. On Fri, Nov 11, 2011 at 2:53 PM, aniket chatterjee aniket...@gmail.comwrote: As far as I understand, your solution will always contain the path that essentially start from root. But the actual problem states that the path may not necessarily start from root. On Fri, Nov 11, 2011 at 1:21 PM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: correct me if I am wrong #includestdio.h struct node { int data; struct node *left; struct node * right; }*root; int sum(int s,struct node *p,int ar[],int l) { if(p == NULL ) { return 0; } if(p-left == NULL p-right == NULL) { if( s - p-data == 0) { ar[l++] = p-data; int i; for( i = 0 ;i l ;i++) { printf(%d ,ar[i]); } printf(\n); } } ar[l++] = p-data; sum(s - p-data, p-left , ar , l); sum(s - p-data, p-right , ar, l); return 0; } struct node * getnode(int k) { struct node *temp = malloc(sizeof(struct node)); temp-data = k; temp-left= NULL; temp-right = NULL; return temp; } main() { int ar[50],value; root = getnode(5); root-left= getnode(2); root-right = getnode(2); root-left-left = getnode(7); root-left-right = getnode(8); root-right-left = getnode(3); root-right-right = getnode(7); value = 14; sum(value,root,ar,0); return 0; } On Fri, Nov 11, 2011 at 12:38 PM, aniket chatterjee aniket...@gmail.comwrote: Write a recursive function that will store each root to leaf path in an array. Now for each root to leaf path find the subarray which sums up to X. On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi All, Please give me the solution of this problem. A binary tree and a number X is given. Find all the paths(not necessarily starting from root) such that the sum equals X. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] BST question
Write a recursive function that will store each root to leaf path in an array. Now for each root to leaf path find the subarray which sums up to X. On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL mnnit.a...@gmail.com wrote: Hi All, Please give me the solution of this problem. A binary tree and a number X is given. Find all the paths(not necessarily starting from root) such that the sum equals X. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] coding round question
+1 On Sun, Oct 30, 2011 at 6:53 AM, Siddhartha Banerjee thefourrup...@gmail.com wrote: could you please explain the question in a bit more detail? especially the partThere are some particular numbers which are made using 4 or 7 : any combination of 4 and 7 are accepted. from what i understand of the question, there are some intervals given... we can move the intervals left or right by one unit, any such movement counts as one move... we have to move the segments in such a way that it maximizes the maximum number of segments where a number can lie...the maximum number of moves allowed are given... is that true??? by the way, which company's coding round was 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Amazon Onsite
Suppose there is a circle. You have five points on that circle. Each point corresponds to a petrol pump. You are given two sets of data. 1. The amount of petrol that petrol pump will give. 2. Distance from that petrol pump tp the next petrol pump. (Assume for 1 lit Petrol the truck will go 1 km) Now calculate the first point from where a truck will be able to complete the circle. (The truck will stop at each petrol pump and it has infinite capacity). Give o(n) solution. You may use o(n) extra space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Output ( File Handling)
i think i should be like this while((c=fgetc(fp))!=EOF) and not getc On Thu, Jul 14, 2011 at 2:41 PM, rShetty rajeevr...@gmail.com wrote: // File Handling #includestdio.h #includestdlib.h int main() { unsigned char ch; // I think there is problem somewhere in this line ! Help !! FILE *fp; fp = fopen(abc,r); if(fp==NULL) { printf(Unable to Open); exit(1); } while((ch = getc(fp)!=EOF)) printf(%c,ch); fclose(fp); printf(\n,ch); return 0; } abc contains some text such as Kicit 44-1 Gokul;peth\0 nagpur What should be the output of the program ?? Explain the solution !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Output ( File Handling)
yeah i just figured it out On Thu, Jul 14, 2011 at 2:47 PM, rajeev bharshetty rajeevr...@gmail.comwrote: @Aniket Its getc itself !! On Thu, Jul 14, 2011 at 2:45 PM, Aniket Dutta aniketdutt...@gmail.comwrote: i think i should be like this while((c=fgetc(fp))!=EOF) and not getc On Thu, Jul 14, 2011 at 2:41 PM, rShetty rajeevr...@gmail.com wrote: // File Handling #includestdio.h #includestdlib.h int main() { unsigned char ch; // I think there is problem somewhere in this line ! Help !! FILE *fp; fp = fopen(abc,r); if(fp==NULL) { printf(Unable to Open); exit(1); } while((ch = getc(fp)!=EOF)) printf(%c,ch); fclose(fp); printf(\n,ch); return 0; } abc contains some text such as Kicit 44-1 Gokul;peth\0 nagpur What should be the output of the program ?? Explain the solution !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Output ( File Handling)
addtion to previous post while((ch=getc(fp))!=EOF) then 2 case will occur On Thu, Jul 14, 2011 at 3:16 PM, Aniket Dutta aniketdutt...@gmail.comwrote: 2. the value of EOF is an integer which equals -1 (0x) and not 0xff becoz this is a valid Ascii character for this reason of tructation the while loop will always be true. On Thu, Jul 14, 2011 at 3:13 PM, Aniket Dutta aniketdutt...@gmail.comwrote: 1. in ur program it will always output 1 because precedence of != is greater than = (assignment) On Thu, Jul 14, 2011 at 2:57 PM, Aniket Dutta aniketdutt...@gmail.comwrote: yeah i just figured it out On Thu, Jul 14, 2011 at 2:47 PM, rajeev bharshetty rajeevr...@gmail.com wrote: @Aniket Its getc itself !! On Thu, Jul 14, 2011 at 2:45 PM, Aniket Dutta aniketdutt...@gmail.comwrote: i think i should be like this while((c=fgetc(fp))!=EOF) and not getc On Thu, Jul 14, 2011 at 2:41 PM, rShetty rajeevr...@gmail.com wrote: // File Handling #includestdio.h #includestdlib.h int main() { unsigned char ch; // I think there is problem somewhere in this line ! Help !! FILE *fp; fp = fopen(abc,r); if(fp==NULL) { printf(Unable to Open); exit(1); } while((ch = getc(fp)!=EOF)) printf(%c,ch); fclose(fp); printf(\n,ch); return 0; } abc contains some text such as Kicit 44-1 Gokul;peth\0 nagpur What should be the output of the program ?? Explain the solution !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Output ( File Handling)
2. the value of EOF is an integer which equals -1 (0x) and not 0xff becoz this is a valid Ascii character for this reason of tructation the while loop will always be true. On Thu, Jul 14, 2011 at 3:13 PM, Aniket Dutta aniketdutt...@gmail.comwrote: 1. in ur program it will always output 1 because precedence of != is greater than = (assignment) On Thu, Jul 14, 2011 at 2:57 PM, Aniket Dutta aniketdutt...@gmail.comwrote: yeah i just figured it out On Thu, Jul 14, 2011 at 2:47 PM, rajeev bharshetty rajeevr...@gmail.comwrote: @Aniket Its getc itself !! On Thu, Jul 14, 2011 at 2:45 PM, Aniket Dutta aniketdutt...@gmail.comwrote: i think i should be like this while((c=fgetc(fp))!=EOF) and not getc On Thu, Jul 14, 2011 at 2:41 PM, rShetty rajeevr...@gmail.com wrote: // File Handling #includestdio.h #includestdlib.h int main() { unsigned char ch; // I think there is problem somewhere in this line ! Help !! FILE *fp; fp = fopen(abc,r); if(fp==NULL) { printf(Unable to Open); exit(1); } while((ch = getc(fp)!=EOF)) printf(%c,ch); fclose(fp); printf(\n,ch); return 0; } abc contains some text such as Kicit 44-1 Gokul;peth\0 nagpur What should be the output of the program ?? Explain the solution !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Aniket Dutta wants to chat
I've been using Google Talk and thought you might like to try it out. We can use it to call each other for free over the internet. Here's an invitation to download Google Talk. Give it a try! --- Aniket Dutta wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-f82fbf59f2-de761d45d3-vNzmtYrn6CV6Ncnyn4yy0qDGTo4 You'll need to click this link to be able to chat with Aniket Dutta. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with Aniket Dutta, visit: http://mail.google.com/mail/a-f82fbf59f2-de761d45d3-vNzmtYrn6CV6Ncnyn4yy0qDGTo4 Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] microsoft ques
@sunny: right thanks for correcting On Wed, Jul 13, 2011 at 11:33 AM, sunny agrawal sunny816.i...@gmail.comwrote: @Aniket Dutta Solution for your case will be 96 Algorithm Posted by Oppilas will do and is O(n). On Wed, Jul 13, 2011 at 11:28 AM, Aniket Dutta aniketdutt...@gmail.comwrote: @vaibhav: Sir ur algo fails in this array {2,-8,-3,1,2} it should give answer as 24 but ur algo gives 2 On Wed, Jul 13, 2011 at 11:02 AM, varun pahwa varunpahwa2...@gmail.comwrote: please ignore my previous post that solution is wrong. On Wed, Jul 13, 2011 at 11:01 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @kranthi : d solution u ve given is only for 2 continuous elements.. wr as d question doesnt limit it to 2.. It can be d product of any no. of continuous elements. So if the array is 200, 5, -2, -3, -1 den ans shd be 200*5*-2*-3 = 6000 N if m workin ur algo in d right way, den it ll give 1000 On Wed, Jul 13, 2011 at 10:52 AM, kranthi kumar damarlakran...@gmail.com wrote: I think this is the solution what u need U can do in O(n) time... #includeiostream using namespace std; main() { int a[7] = { 0, 0, 0, 19, 380, -1, 2}; int prod, nprod; bool x = false; for(int i=0;i6;i++) { nprod = a[i] * a[i+1]; coutnprodendl; if( x == false) { x = true; prod = nprod; } else if( x== true prod nprod ) prod = nprod; } cout\nResult: prod; } -- Regards: --- D Kranthi kumar Computer Science Engg. 1st Mtech, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.
Re: [algogeeks] microsoft ques
what happens when to the '{' in comments i guess your program is also counting that.. On Tue, Jul 12, 2011 at 6:22 PM, nicks crazy.logic.k...@gmail.com wrote: igonre the previous code, here is fully working code..previous one doesn't include check for having { within quotes which should not be counted for scope depth #includestdio.h int main() { int depth=0,max=0; char c,temp; while((c=getchar())!=EOF) { if(c== '{' ) { depth+=1; if(depthmax) max=depth; } else if(c== '}' ) { depth-=1; } else if(c=='\'||c==39) { temp=c; while((c=getchar())!=temp); //skipping all the characters till next quote occurs } } printf(%d\n,max); } 39 is ASCII code for ' it was giving error when i tried to write it like '''.so i replaced it with its ASCII to save timesomeone please suggest the proper way to writing it... the code is working fine for this code as input output is 3..if any constraints are left then please suggest !! On Tue, Jul 12, 2011 at 5:50 PM, nicks crazy.logic.k...@gmail.com wrote: my bad...that should be understood.. On Tue, Jul 12, 2011 at 5:45 PM, Vandana Bachani vandana@gmail.comwrote: You have the right braces missing, it would result in a 0 depth for all cases. (Precedence of != is greater than =) On Tue, Jul 12, 2011 at 5:41 PM, nicks crazy.logic.k...@gmail.comwrote: i thought of this code..i think it should work.correct me if i am wrong depth=0;max=0; while(*(*c=getchar()*)*!=EOF) { if(c== '{' ) { depth+=1 if(depthmax) max=depth; } else if(c== '}' ) { depth-=1; } } On Tue, Jul 12, 2011 at 4:55 PM, Sandeep Jain sandeep6...@gmail.comwrote: If we just have to give the depth as in count then, I believe we can use stack to push/pop curly braces. While maintaining the maximum depth observed And if we have to display/print line numbers or code itself, then converting the code in a tree structure should help. Each node can contain the line/col position of starting/closing braces. Each node will have its nested braces as child nodes. PS: In either case make sure you ignore comments and strings literals Regards, Sandeep Jain On Tue, Jul 12, 2011 at 4:43 PM, shilpa gupta shilpagupta...@gmail.com wrote: Write down the c code for finding out the maximum scope depth in a c code. A scope depth is increased by one with every '{' and decreases by one with every '}' -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. On Tue, Jul 12, 2011 at 4:55 PM, Sandeep Jain sandeep6...@gmail.comwrote: If we just have to give the depth as in count then, I believe we can use stack to push/pop curly braces. While maintaining the maximum depth observed And if we have to display/print line numbers or code itself, then converting the code in a tree structure should help. Each node can contain the line/col position of starting/closing braces. Each node will have its nested braces as child nodes. PS: In either case make sure you ignore comments and strings literals Regards, Sandeep Jain On Tue, Jul 12, 2011 at 4:43 PM, shilpa gupta shilpagupta...@gmail.com wrote: Write down the c code for finding out the maximum scope depth in a c code. A scope depth is increased by one with every '{' and decreases by one with every '}' -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to
Re: [algogeeks] microsoft ques
for example /* { { } }*/ On Tue, Jul 12, 2011 at 6:36 PM, Aniket Dutta aniketdutt...@gmail.comwrote: what happens when to the '{' in comments i guess your program is also counting that.. On Tue, Jul 12, 2011 at 6:22 PM, nicks crazy.logic.k...@gmail.com wrote: igonre the previous code, here is fully working code..previous one doesn't include check for having { within quotes which should not be counted for scope depth #includestdio.h int main() { int depth=0,max=0; char c,temp; while((c=getchar())!=EOF) { if(c== '{' ) { depth+=1; if(depthmax) max=depth; } else if(c== '}' ) { depth-=1; } else if(c=='\'||c==39) { temp=c; while((c=getchar())!=temp); //skipping all the characters till next quote occurs } } printf(%d\n,max); } 39 is ASCII code for ' it was giving error when i tried to write it like '''.so i replaced it with its ASCII to save timesomeone please suggest the proper way to writing it... the code is working fine for this code as input output is 3..if any constraints are left then please suggest !! On Tue, Jul 12, 2011 at 5:50 PM, nicks crazy.logic.k...@gmail.comwrote: my bad...that should be understood.. On Tue, Jul 12, 2011 at 5:45 PM, Vandana Bachani vandana@gmail.comwrote: You have the right braces missing, it would result in a 0 depth for all cases. (Precedence of != is greater than =) On Tue, Jul 12, 2011 at 5:41 PM, nicks crazy.logic.k...@gmail.comwrote: i thought of this code..i think it should work.correct me if i am wrong depth=0;max=0; while(*(*c=getchar()*)*!=EOF) { if(c== '{' ) { depth+=1 if(depthmax) max=depth; } else if(c== '}' ) { depth-=1; } } On Tue, Jul 12, 2011 at 4:55 PM, Sandeep Jain sandeep6...@gmail.comwrote: If we just have to give the depth as in count then, I believe we can use stack to push/pop curly braces. While maintaining the maximum depth observed And if we have to display/print line numbers or code itself, then converting the code in a tree structure should help. Each node can contain the line/col position of starting/closing braces. Each node will have its nested braces as child nodes. PS: In either case make sure you ignore comments and strings literals Regards, Sandeep Jain On Tue, Jul 12, 2011 at 4:43 PM, shilpa gupta shilpagupta...@gmail.com wrote: Write down the c code for finding out the maximum scope depth in a c code. A scope depth is increased by one with every '{' and decreases by one with every '}' -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. On Tue, Jul 12, 2011 at 4:55 PM, Sandeep Jain sandeep6...@gmail.comwrote: If we just have to give the depth as in count then, I believe we can use stack to push/pop curly braces. While maintaining the maximum depth observed And if we have to display/print line numbers or code itself, then converting the code in a tree structure should help. Each node can contain the line/col position of starting/closing braces. Each node will have its nested braces as child nodes. PS: In either case make sure you ignore comments and strings literals Regards, Sandeep Jain On Tue, Jul 12, 2011 at 4:43 PM, shilpa gupta shilpagupta...@gmail.com wrote: Write down the c code for finding out the maximum scope depth in a c code. A scope depth is increased by one with every '{' and decreases by one with every '}' -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
Re: [algogeeks] Re: Search node in a binary tree
@bittu On 7/12/11, Aniket Dutta aniketdutt...@gmail.com wrote: what will happen if node is not found?. you are not checking it On 7/12/11, bittu shashank7andr...@gmail.com wrote: whats the problem with this bool search(root,node) { if(root==node) return 1; else return search(root-left,node)||search(root-right,node); } TC O(N) notify me via mail if anything wrong.? Thanks Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Search node in a binary tree
what will happen if node is not found?. you are not checking it On 7/12/11, bittu shashank7andr...@gmail.com wrote: whats the problem with this bool search(root,node) { if(root==node) return 1; else return search(root-left,node)||search(root-right,node); } TC O(N) notify me via mail if anything wrong.? Thanks Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Search node in a binary tree
@yeah right On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Aniket: Just add a condition at the begining: if(root == NULL) return 0; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Search node in a binary tree
@bittu On Tue, Jul 12, 2011 at 8:09 PM, Aniket Dutta aniketdutt...@gmail.comwrote: @yeah right On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Aniket: Just add a condition at the begining: if(root == NULL) return 0; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Search node in a binary tree
sorry @ankit On Tue, Jul 12, 2011 at 8:10 PM, Aniket Dutta aniketdutt...@gmail.comwrote: @bittu On Tue, Jul 12, 2011 at 8:09 PM, Aniket Dutta aniketdutt...@gmail.comwrote: @yeah right On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Aniket: Just add a condition at the begining: if(root == NULL) return 0; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: linked list doubt
@anika: according to satistics we need both n/2 and n/2+1 to find the median from an even set ((n/2)+(n/2+1))/2. but here you cannot do this. so i guess n/2+1 or n/2 both are correct because both contribute equally to calculate median. On 7/12/11, bittu shashank7andr...@gmail.com wrote: now try how u will remove the loop from linked list Shashank CSE BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] output
@dheeraj: but the prototypes are same. how u are calling it overloading plz explain On 7/12/11, dheeraj tyagi dheeraj2...@gmail.com wrote: const means that it cannot be overloaded..i think due to that this is happening. On Tue, Jul 12, 2011 at 9:26 PM, segfault pawan1991ya...@gmail.com wrote: #includeiostream using namespace std; class x{ public: x() {} int func() const{ coutit is const function\n; } int func() { coutit is simple functin\n; } }; int main() { x a; a.func(); return 0; } why cann't it take const function? explain 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. -- With regards Dheeraj Tyagi 8197218001 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] output
@sandeep sir: thanx sir for clearing doubt On 7/12/11, Sandeep Jain sandeep6...@gmail.com wrote: *const* in C++ is not exactly same as *final* in java. SO unlike java adding the keyword const to a function does not affect overriding. Infact, adding in C++ const functions == that they will not modify any member of the class. non-const functions cannot be invoked by const objects. Try making object 'a' as const i.e. const x a; and then invoke f(), it should invoke the correct version. Note that C++ allows function overloading based on const-ness. Refer (Const function section) http://www.cprogramming.com/tutorial/const_correctness.html Also, subscript operators generally come in pairs, Refer http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.10 http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.12 Regards, Sandeep Jain On Tue, Jul 12, 2011 at 10:09 PM, dheeraj tyagi dheeraj2...@gmail.comwrote: const means that it cannot be overloaded..i think due to that this is happening. On Tue, Jul 12, 2011 at 9:26 PM, segfault pawan1991ya...@gmail.comwrote: #includeiostream using namespace std; class x{ public: x() {} int func() const{ coutit is const function\n; } int func() { coutit is simple functin\n; } }; int main() { x a; a.func(); return 0; } why cann't it take const function? explain 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. -- With regards Dheeraj Tyagi 8197218001 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] questions related to C
c=a+b then find b=c-a; if this b equals previous one then ok else overflow On 7/9/11, John Hayes agressiveha...@gmail.com wrote: regarding question related to overflow int ovr_sum(int *sum,int a,int b) { *sum=a+b if(*sum0) return -1; //overflow else return 0; //no problem with the sum (overflow don't occur) } On Sat, Jul 9, 2011 at 2:05 PM, John Hayes agressiveha...@gmail.com wrote: generic swap can be written as - #define Swap(T, a, b) {T temp = a; a=b; b=temp;} this is working fine in gcc On Sat, Jul 9, 2011 at 1:45 PM, saurabh singh saurab...@gmail.com wrote: #includestdio.h #includeerror.h #includemalloc.h #includestdlib.h void swap(void *p1,void *p2,const unsigned size) { char *buff=(char*) malloc(size*sizeof(char)); if(!buff) { perror(malloc); exit(11); } memcpy(buff,p1,size); memcpy(p1,p2,size); memcpy(p2,buff,size); free(buff); return; } int main() { int a=12,b=24; char c='a',d='b'; float e=1.1f,f=2.3f; char wrd1[]=Hello; char wrd2[]=Bye; char *p=wrd1; char *q=wrd2; swap(a,b,sizeof(int)); swap(c,d,sizeof(char)); swap(e,f,sizeof(float)); swap(p,q,sizeof(p)); printf(%d\t%d\n,a,b); printf(%c\t%c\n,c,d); printf(%f\t%f\n,e,f); printf(%s\t%s\n,p,q); return 0; } Its a generic function not a macro, I know but the idea would be same. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Interview
you can sort it using external merge sort. if ur file is greater than memory refer henry F. korth Database System Concept On Wed, Jul 13, 2011 at 10:26 AM, rShetty rajeevr...@gmail.com wrote: Given a very big file of words, a word in each line, sort the words . Please provide the algorithm and explanation . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: questions related to C
what about a generic swap function which works for structures also? On Wed, Jul 13, 2011 at 2:23 AM, Don dondod...@gmail.com wrote: To check for overflow, use condition: if (b (maxuint-a)) return error; Where maxuint is the largest value which can be stored in an unsigned integer. Don On Jul 8, 5:50 am, vikas mehta...@gmail.com wrote: Q1 - write a generic macro to swap two values (int,float,double,pointers as well ) Q2 - Implement your own malloc() and free() function Q3 - Two unsigned ints given a, b you have add these numbers and return the sum ...Make sure in case of overflow return error. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] microsoft ques
@vaibhav: Sir ur algo fails in this array {2,-8,-3,1,2} it should give answer as 24 but ur algo gives 2 On Wed, Jul 13, 2011 at 11:02 AM, varun pahwa varunpahwa2...@gmail.comwrote: please ignore my previous post that solution is wrong. On Wed, Jul 13, 2011 at 11:01 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @kranthi : d solution u ve given is only for 2 continuous elements.. wr as d question doesnt limit it to 2.. It can be d product of any no. of continuous elements. So if the array is 200, 5, -2, -3, -1 den ans shd be 200*5*-2*-3 = 6000 N if m workin ur algo in d right way, den it ll give 1000 On Wed, Jul 13, 2011 at 10:52 AM, kranthi kumar damarlakran...@gmail.com wrote: I think this is the solution what u need U can do in O(n) time... #includeiostream using namespace std; main() { int a[7] = { 0, 0, 0, 19, 380, -1, 2}; int prod, nprod; bool x = false; for(int i=0;i6;i++) { nprod = a[i] * a[i+1]; coutnprodendl; if( x == false) { x = true; prod = nprod; } else if( x== true prod nprod ) prod = nprod; } cout\nResult: prod; } -- Regards: --- D Kranthi kumar Computer Science Engg. 1st Mtech, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] PHP E-Book
Please suggest me a standard PHP book.I know there are lots in the internet.But as I am a beginner I want suggestions.Also if possible send the book or give me the link.Thanks in advance. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Problem regarding MySql server Installation
I was trying to install mysql 5.5. in Windows XP.After installation during configuration phase when there was to apply security settings I m always getting an error Error No 1045 Access Denied for user 'root'@localhost(using password: NO). I have tried all possibilities in Firewall but it dint work.Hope anybody here will help me out of this problem.I am totally screwed up!!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c programming question
The answer will be compiler dependent.Google Sequence Point in C. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] can i know the best way to learn programming??
@Rahul: Awesome link dude!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Google Question
It will be like a circularly sorted array.There exists a binary search type divide and conquer mechanism to find a specific number in such type of arrays. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] MICROSOFT IDC
Is there any way to do it using recursion? Interviewer asked to do it using recursion. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MICROSOFT IDC
Hi all Its about set intersection. @Davin predicted the problem wrongly. So,sorting gives the best performance. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MICROSOFT IDC
Hi all Its about set intersection. @Davin predicted the problem wrongly. So,sorting gives the best performance. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] MICROSOFT IDC
Find the intersection of two unsorted singly linked list in O(1) space and less than O(n^2) complexity. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Please Explain
#includeiostream using namespace std; const int a[]={1,2,3,4,5}; int b[a[2]]; int main(){return 0;} If the code is like above it is giving error in line 4; But if it is something like below it gives no error after compilation: #includeiostream using namespace std; const int a=3; int b[a]; int main(){return 0;} Anybody please expalin. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Float Comparison
This link may be helpful: http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Longest Palindrome
@Anand:I went through the link posted in your blog.But I found the method little bit hard to understand. @Aviral:Please elaborate the approach or give some link as in your blog I didn't find the solution. It will be very helpful.Thanks in advance. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Plz Explain The Output.
# include stdio.h #includeconio.h #define concatinate(a,b) a##b #define same1(a) #a #define same2(a) same1(a) int main(){ printf(%s\n,same2(concatinate(1,2))); printf(%s\n,same1(concatinate(1,2))); getch(); return 0; } Output is: 12 concatinate(1,2) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Plz Explain The Output.
2. #includeiostream using namespace std; int main(){ int n = 255, i; char *p = (char *)n; for(i = 0; i sizeof(int); i++) cout(unsigned int)p[i]\n; cin.get(); return 0; } Output: 4294967295 0 0 0 I think p[0] is .So why it is giving 4294967295 in the first line. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Longest Palindrome
How do you find the longest palindrome in a given string in O(n) time? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] 10 Most Frequent Search Text
@Chi: Would you please explain the process in a little bit more details? It will be helpful. Is Trie and Radix-Trie same? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] DIVIDE TWO VARYING LENGTH NUMBERS.
DIVIDE TWO VARYING LENGTH NUMBERS EX: ONE CAN BE UPTO 60 DIGIT AND OTHER 40 DIGIT Well,I thought of an approach.Store each digit of each number in two separate integer arrays(From right to left).Then apply the subtraction method.Will it be feasible? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.