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.
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.
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.
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.
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.