Re: [algogeeks] Question asked in Amazon Online Test
i think this algo will do... reverse the given prefix expression while(!nd of input) { if it is operand push in a stack if its an operator { op1=pop(stack); op2=pop(stack); push (op1 op2 operator) on to stack; } } On Sat, Jun 30, 2012 at 1:56 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: example -+53+2/36 step 1: 63/2+35+- step 2: 36/2+53+- On Sat, Jun 30, 2012 at 1:55 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: reverse the prefix notation and then reverse each continuous occurence of operands On Sat, Jun 30, 2012 at 12:50 AM, Abhishek Sharma abhi120...@gmail.comwrote: convert prefix to infix,then convert infix to postfix.Now, to convert prefix to infix, push numbers in one stack and operators in other.Then use thishttp://www.velocityreviews.com/forums/t445633-prefix-to-infix-conversion.html algo to perform this.Then do the same for infix to postfix.It works with simple operators,but difficult to implement with parenthesis. On Sat, Jun 30, 2012 at 12:21 AM, rahul ranjan rahul.ranjan...@gmail.com wrote: oh bhai mere. kewal preorder use karke kaise tree bana dega??? On Fri, Jun 29, 2012 at 11:23 PM, amrit harry dabbcomput...@gmail.comwrote: @bhaskar ur algo fails on this case (5+3)-(2+(3/6)) -+53+2/36 63/2+35-+ showing that 6/3 but actually it is 3/6 so i think it could be done by folowing algo make a binary tree of given expression in O(n) then do postorder traversal take O(n) so problem can be solved in O(n). and take O(2*n+1) space On Fri, Jun 29, 2012 at 9:13 PM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: I think just reversing the prefix notation converts it to postfix notation On Fri, Jun 29, 2012 at 7:46 PM, Gobind Kumar Hembram gobind@gmail.com wrote: Given an integer expression in a prefix format (i.e. the operator precedes the number it is operating on) , print the expression in the post fix format . Example: If the integer expression is in the prefix format is *+56-78, the postfix format expression is 56+78-*. Both of these correspond to the expression (5+6)*(7-8). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. 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. -- Thanks Regards Amritpal 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Abhishek Sharma Under-Graduate Student, PEC University 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. -- regards, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. Allahabad -- regards, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. 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 Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more
Re: [algogeeks] Microsoft interview qs
i am not sure if it is possible to change the length of an already declared array, so i think one might wanna use pointers instead. Allocate memory dynamically. On Thu, Jun 28, 2012 at 2:36 PM, deepikaanand swinyanand...@gmail.comwrote: //Taken from careercup.com Design the autocomplete feature (ex:Google Suggest) I assumed {abcde,abcegh,abcpqr,abcxyz,xyz ,abcmno} URLs and stored them in trie...Such if the user enters abc ...the o/p will be abc is a prefix in 5 number of cases d e e g h m n o p q r x y z Now say if I add more strings of the form abcdpqr,abcdprst..How can I modify this code such that now thw o/p is d e e g h m n o p q r x y z d p q r d p r s t code in c :- http://ideone.com/rBvQb -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] eight queens on lisp
even i dont know how to code in LISP, but this might help http://obereed.net/queens/algorithm.html On Fri, Jun 29, 2012 at 5:45 AM, Victor Manuel Grijalva Altamirano kavic1.mar...@gmail.com wrote: Hi i need your help, i need to programm the problem eight queens in LISP. I´m learning LISP, but i´m new... Anybody can help me? I have the idea of backtracking, but i don´t know how to code it in LISP... -- Victor Manuel Grijalva Altamirano Universidad Tecnologica de La Mixteca -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Sequence problem
find the nth term for the sequence... 3, 8, 12, 17, 22, 28, 35 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Help needed for telephonic interview from Amazon banglore.
Hi I have one year experience and have interview scheduled on monday. Pease help me with your experience or knowledge regarding questions, strategy and any misc aspect. Thanks in advance -- 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/-/wmSwLUDkhY8J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 interview qs
trie or ternary tree and build stack for the string being entered, keep distributed hashmap for head/tail queries like cricket, weather, finance etc various domains etc.. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, Jun 30, 2012 at 12:05 PM, shady sinv...@gmail.com wrote: i am not sure if it is possible to change the length of an already declared array, so i think one might wanna use pointers instead. Allocate memory dynamically. On Thu, Jun 28, 2012 at 2:36 PM, deepikaanand swinyanand...@gmail.comwrote: //Taken from careercup.com Design the autocomplete feature (ex:Google Suggest) I assumed {abcde,abcegh,abcpqr,abcxyz,xyz ,abcmno} URLs and stored them in trie...Such if the user enters abc ...the o/p will be abc is a prefix in 5 number of cases d e e g h m n o p q r x y z Now say if I add more strings of the form abcdpqr,abcdprst..How can I modify this code such that now thw o/p is d e e g h m n o p q r x y z d p q r d p r s t code in c :- http://ideone.com/rBvQb -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Question asked in Amazon Online Test
@bhaskar himanshu :- can u please explain ur algo for a * ( b + ( ( c - d ) / e ) ) On Sat, Jun 30, 2012 at 11:50 AM, himanshu kansal himanshukansal...@gmail.com wrote: i think this algo will do... reverse the given prefix expression while(!nd of input) { if it is operand push in a stack if its an operator { op1=pop(stack); op2=pop(stack); push (op1 op2 operator) on to stack; } } On Sat, Jun 30, 2012 at 1:56 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: example -+53+2/36 step 1: 63/2+35+- step 2: 36/2+53+- On Sat, Jun 30, 2012 at 1:55 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: reverse the prefix notation and then reverse each continuous occurence of operands On Sat, Jun 30, 2012 at 12:50 AM, Abhishek Sharma abhi120...@gmail.comwrote: convert prefix to infix,then convert infix to postfix.Now, to convert prefix to infix, push numbers in one stack and operators in other.Then use thishttp://www.velocityreviews.com/forums/t445633-prefix-to-infix-conversion.html algo to perform this.Then do the same for infix to postfix.It works with simple operators,but difficult to implement with parenthesis. On Sat, Jun 30, 2012 at 12:21 AM, rahul ranjan rahul.ranjan...@gmail.com wrote: oh bhai mere. kewal preorder use karke kaise tree bana dega??? On Fri, Jun 29, 2012 at 11:23 PM, amrit harry dabbcomput...@gmail.com wrote: @bhaskar ur algo fails on this case (5+3)-(2+(3/6)) -+53+2/36 63/2+35-+ showing that 6/3 but actually it is 3/6 so i think it could be done by folowing algo make a binary tree of given expression in O(n) then do postorder traversal take O(n) so problem can be solved in O(n). and take O(2*n+1) space On Fri, Jun 29, 2012 at 9:13 PM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: I think just reversing the prefix notation converts it to postfix notation On Fri, Jun 29, 2012 at 7:46 PM, Gobind Kumar Hembram gobind@gmail.com wrote: Given an integer expression in a prefix format (i.e. the operator precedes the number it is operating on) , print the expression in the post fix format . Example: If the integer expression is in the prefix format is *+56-78, the postfix format expression is 56+78-*. Both of these correspond to the expression (5+6)*(7-8). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. 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. -- Thanks Regards Amritpal 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Abhishek Sharma Under-Graduate Student, PEC University 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. -- regards, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. Allahabad -- regards, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. 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 Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google
Re: [algogeeks] Re: [Google] Finds all the elements that appear more than n/3 times
@above On Thursday, 28 June 2012 04:05:12 UTC+5:30, Navin Kumar wrote: Design an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time ( n =0 ). You are expected to use comparisons and achieve linear time. No hashing/excessive space/ and don't use standard linear time deterministic selection algo. On Thursday, 28 June 2012 04:05:12 UTC+5:30, Navin Kumar wrote: Design an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time ( n =0 ). You are expected to use comparisons and achieve linear time. No hashing/excessive space/ and don't use standard linear time deterministic selection algo. On Thursday, 28 June 2012 04:05:12 UTC+5:30, Navin Kumar wrote: Design an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time ( n =0 ). You are expected to use comparisons and achieve linear time. No hashing/excessive space/ and don't use standard linear time deterministic selection algo. -- 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/-/0myz4OIStO8J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Microsoft Interview Question
@Dave :- a minor change Initially, decrement the end pointer till it points to positive number, Now end points to the last negative number. Now, If current is negative , increment current If current is positive , swap it with the element at end and decrement current and end both If current = end , then break. Algo :- cur = 0; end = size - 1; while ( a[end] 0 end 0 ) end - - ; while ( cur end ) { if( a[cur] 0 ) cur++; else{ swap( a[cur], a[end] ); end - - ; } // end of if-else } // end of while In the above example :- ( 1, -1, 2 ), current points to 1 (cur=0) and end points to -1 (end =1 )after end has been decremented. Now swap the element at current and end pointers. Now cur = 0, end =0, break condition is reached. the output is :- ( -1, 1, 2 ) Please check. Navin Kumar Gupta Final Year, B.Tech (Hons.) Computer Science Engg. National Institute of Technology,Jamshedpur Mob - (+91) 8285303045 On Friday, 29 June 2012 22:28:15 UTC+5:30, Dave wrote: @Navin: Try this with {1,-1,2}. current points to the 1 and end points to the 2. Since 1 is positive, the algorithm swaps the 1 and the 2, giving {2,-1,1}. Then it decrements current to point outside the array and end to point to the -1. How can this be right? Dave -- 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/-/bseavL7x8OQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Fixing Up The Binary Search Tree
An unbalanced BST can be converted to a balanced BST in following 2-steps. 1:- Convert the tree to sorted circular doubly linked list. http://www.leetcode.com/2010/11/convert-binary-search-tree-bst-to.html The left children points to previous element and right children points to next element. - O( N ) 2:- Now convert the doubly linked list into tree recursively. -O(N) http://www.geeksforgeeks.org/archives/17063 Return the root of the new tree formed.-- Navin Kumar Gupta Final Year,B.Tech(Hons.) Computer Science Engg. National Institute of Technology,Jamshedpur Mobile - (+91)8285303045 -- 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/-/DxrZjNYzR_wJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Question asked in Amazon Online Test
I think no need to reverse the string,following program is giving me correct o/p.Although right now this program will work only for binary operator,for unary add extra condition main() { char str[100]; int i=0; int digit; scanf(%s,str); while(str[i]) { if(isdigit(str[i])) { printf(%c,str[i]); if(isdigit(str[i+1])) { printf(%c,str[i+1]); digit=popstack(); printf(%c,digit); i++; } } else if(str[i]=33 str[i]=47) { pushstack(str[i]); } i++; } while(top!=0) { digit=popstack(); printf(%c,digit); } } On Sat, Jun 30, 2012 at 11:50 AM, himanshu kansal himanshukansal...@gmail.com wrote: i think this algo will do... reverse the given prefix expression while(!nd of input) { if it is operand push in a stack if its an operator { op1=pop(stack); op2=pop(stack); push (op1 op2 operator) on to stack; } } On Sat, Jun 30, 2012 at 1:56 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: example -+53+2/36 step 1: 63/2+35+- step 2: 36/2+53+- On Sat, Jun 30, 2012 at 1:55 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: reverse the prefix notation and then reverse each continuous occurence of operands On Sat, Jun 30, 2012 at 12:50 AM, Abhishek Sharma abhi120...@gmail.comwrote: convert prefix to infix,then convert infix to postfix.Now, to convert prefix to infix, push numbers in one stack and operators in other.Then use thishttp://www.velocityreviews.com/forums/t445633-prefix-to-infix-conversion.html algo to perform this.Then do the same for infix to postfix.It works with simple operators,but difficult to implement with parenthesis. On Sat, Jun 30, 2012 at 12:21 AM, rahul ranjan rahul.ranjan...@gmail.com wrote: oh bhai mere. kewal preorder use karke kaise tree bana dega??? On Fri, Jun 29, 2012 at 11:23 PM, amrit harry dabbcomput...@gmail.com wrote: @bhaskar ur algo fails on this case (5+3)-(2+(3/6)) -+53+2/36 63/2+35-+ showing that 6/3 but actually it is 3/6 so i think it could be done by folowing algo make a binary tree of given expression in O(n) then do postorder traversal take O(n) so problem can be solved in O(n). and take O(2*n+1) space On Fri, Jun 29, 2012 at 9:13 PM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: I think just reversing the prefix notation converts it to postfix notation On Fri, Jun 29, 2012 at 7:46 PM, Gobind Kumar Hembram gobind@gmail.com wrote: Given an integer expression in a prefix format (i.e. the operator precedes the number it is operating on) , print the expression in the post fix format . Example: If the integer expression is in the prefix format is *+56-78, the postfix format expression is 56+78-*. Both of these correspond to the expression (5+6)*(7-8). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. 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. -- Thanks Regards Amritpal 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Abhishek Sharma Under-Graduate Student, PEC University 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. -- regards, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. Allahabad -- regards, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. Allahabad -- You received this message
Re: [algogeeks] Re: Fixing Up The Binary Search Tree
@navin : +1 On 6/30/12, Navin Gupta navin.nit...@gmail.com wrote: An unbalanced BST can be converted to a balanced BST in following 2-steps. 1:- Convert the tree to sorted circular doubly linked list. http://www.leetcode.com/2010/11/convert-binary-search-tree-bst-to.html The left children points to previous element and right children points to next element. - O( N ) 2:- Now convert the doubly linked list into tree recursively. -O(N) http://www.geeksforgeeks.org/archives/17063 Return the root of the new tree formed.-- Navin Kumar Gupta Final Year,B.Tech(Hons.) Computer Science Engg. National Institute of Technology,Jamshedpur Mobile - (+91)8285303045 -- 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/-/DxrZjNYzR_wJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] adobe
these are asked for which profyl??developer or white box?? On Sat, Jun 30, 2012 at 8:03 PM, Amol Sharma amolsharm...@gmail.com wrote: @sarthak : in your first solution aren't you using nrows+1 malloc's ? second solution is good using 1 malloc. -- Amol Sharma Final Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://www.simplyamol.blogspot.com/http://facebook.com/amolsharma99 On Fri, Jun 29, 2012 at 5:35 PM, sarthak rai sarthakra...@gmail.comwrote: 2 malloc(): int **a=(int **)malloc(sizeof(int *)*nrows); for(i=0;inrows;i++) a[i]=(int *)malloc(sizeof(int)*ncols); using only 1 malloc: int **a=(int **)malloc(sizeof(int *)*nrows+(nrows*ncols)*(sizeof(int))); for(i=0;inrows;i++) { a[i]=(int*)(a+nrows+i*ncols); } On Fri, Jun 29, 2012 at 4:46 PM, rahul r. srivastava rahul.ranjan...@gmail.com wrote: implement a 2d matrix using only 2 mallocs. -- 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/-/s4vvxtO2yVsJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] adobe
i dont knw read it in some paper.. most prob developer. On Sat, Jun 30, 2012 at 9:56 PM, rahul sharma rahul23111...@gmail.comwrote: these are asked for which profyl??developer or white box?? On Sat, Jun 30, 2012 at 8:03 PM, Amol Sharma amolsharm...@gmail.comwrote: @sarthak : in your first solution aren't you using nrows+1 malloc's ? second solution is good using 1 malloc. -- Amol Sharma Final Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://www.simplyamol.blogspot.com/http://facebook.com/amolsharma99 On Fri, Jun 29, 2012 at 5:35 PM, sarthak rai sarthakra...@gmail.comwrote: 2 malloc(): int **a=(int **)malloc(sizeof(int *)*nrows); for(i=0;inrows;i++) a[i]=(int *)malloc(sizeof(int)*ncols); using only 1 malloc: int **a=(int **)malloc(sizeof(int *)*nrows+(nrows*ncols)*(sizeof(int))); for(i=0;inrows;i++) { a[i]=(int*)(a+nrows+i*ncols); } On Fri, Jun 29, 2012 at 4:46 PM, rahul r. srivastava rahul.ranjan...@gmail.com wrote: implement a 2d matrix using only 2 mallocs. -- 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/-/s4vvxtO2yVsJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.
[algogeeks] Re: first Repeating character in a string
Use an array count[26][2]. Here first col of each row represents the position of first instance of the alphabet,if any, else -1. and second col of each row represents the position of last repeated instance of the alphabet, if any, else -1. Now traverse the count array to find the row having both values positive.Of all these rows,the the row having minimum count[i][0] can be found in linear time . The alphabet corresponding to that position is the answer. Algo :- int count[26][2]. initialise each element of count to -1. Now, start from pos 0 and for each char c at position pos in the string if ( count[c-'a'][0] == -1) count[ c- 'a' ][0] = pos; else count[ c- 'a' ][1] = pos; int first_repeating_pos = INT_MAX; for(int i=0;i26;i++) if( count[i][0] =0 count[i][1] =0) if(count[i][0] first_repeating_pos) first_repeating_pos = count[i][0]; -- Navin Kumar Gupta Final Year,B.Tech(Hons.) Computer Science Engg. National Institute of Technology,Jamshedpur Mobile - (+91)8285303045 -- 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/-/l_FbUt4SBSIJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 interview qs
i have fixed your code but it is alwayz better to use recursive function for creating trie. i have wrote my own recursive function to create TRIE... you can understand the same bcozz iterative one make thing unnecessary complicated. here check the code link :- http://ideone.com/6HhFZ have fun :) :) On 6/28/12, deepikaanand swinyanand...@gmail.com wrote: //Taken from careercup.com Design the autocomplete feature (ex:Google Suggest) I assumed {abcde,abcegh,abcpqr,abcxyz,xyz ,abcmno} URLs and stored them in trie...Such if the user enters abc ...the o/p will be abc is a prefix in 5 number of cases d e e g h m n o p q r x y z Now say if I add more strings of the form abcdpqr,abcdprst..How can I modify this code such that now thw o/p is d e e g h m n o p q r x y z d p q r d p r s t code in c :- http://ideone.com/rBvQb -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Microsoft Interview Question
@Navin: If I am correctly executing your algorithm on the data in the original posting, {-1,5,3,-8,4,-6,9}, I get {-1,-6,-8,4,3,5,9}, when the correct answer is {-1,-8,-6,5,3,4,9}. The array contains the correct numbers, but the order of the positive numbers and the order of the negtive numbers is not maintained. You can't swap a number from the front part of the array with a number from the back part and expect the order of positives and negatives to remain intact. Dave On Saturday, June 30, 2012 12:42:09 AM UTC-5, Navin Gupta wrote: @Dave :- a minor change Initially, decrement the end pointer till it points to positive number, Now end points to the last negative number. Now, If current is negative , increment current If current is positive , swap it with the element at end and decrement current and end both If current = end , then break. Algo :- cur = 0; end = size - 1; while ( a[end] 0 end 0 ) end - - ; while ( cur end ) { if( a[cur] 0 ) cur++; else{ swap( a[cur], a[end] ); end - - ; } // end of if-else } // end of while In the above example :- ( 1, -1, 2 ), current points to 1 (cur=0) and end points to -1 (end =1 )after end has been decremented. Now swap the element at current and end pointers. Now cur = 0, end =0, break condition is reached. the output is :- ( -1, 1, 2 ) Please check. Navin Kumar Gupta Final Year, B.Tech (Hons.) Computer Science Engg. National Institute of Technology,Jamshedpur Mob - (+91) 8285303045 On Friday, 29 June 2012 22:28:15 UTC+5:30, Dave wrote: @Navin: Try this with {1,-1,2}. current points to the 1 and end points to the 2. Since 1 is positive, the algorithm swaps the 1 and the 2, giving {2,-1,1}. Then it decrements current to point outside the array and end to point to the -1. How can this be right? Dave -- 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/-/97r3CtynC8oJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 help in understanding this question. I have no answers just this question.
Given matrix(screen black n white)..where 1 represents black dot and 0=white. there can b many images/objects in it..return list of coordinates for each obkect..(Hint do BFS) -- 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/-/3F5k2u0wwWwJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.