[algogeeks] google written

2011-01-14 Thread snehal jain
Write the code to find lexicographic minimum in a circular array, e.g. for the array BCABDADAB, the lexicographic mininum is ABBCABDAD. -- 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] Re: Amazon Interview - Algorithms

2011-01-14 Thread Decipher
I don't think the inner loop is executing only once . Kindly check it for this test case {1,3,5,8,9,2,6,7,6,8,9} . And try to print i in inner loop you will find that for same values of i(Outer index) inner loop is called. Its an O(n2) solution . -- You received this message because you are

Re: [algogeeks] probability

2011-01-14 Thread Wei.QI
x is even number probability 0.9x + x = 1 x = 1/1.9 P(2) = P(4) = P(6) = (1 / 1.9) / 3 P(4|5|6) = (P(4) + P(6)) / 0.75 = 2 / 1.9 / 3 / 0.75 = 0.4678362573099415 -weiq On Thu, Jan 13, 2011 at 11:29 PM, snehal jain learner@gmail.com wrote: An unbalanced dice (with 6 faces, numbered from 1 to

Re: [algogeeks] BT

2011-01-14 Thread anoop chaurasiya
if the root of T2 is duplicated in T1,this code may give a wrong answer(as there is no provision of backtracking in case there is a mis match after some matchings).given above KMP is the best possible answer i think.. On Wed, Jan 12, 2011 at 11:28 AM, pacific pacific

Re: [algogeeks] google written

2011-01-14 Thread radha krishnan
wow This s a spoj problem http://www.spoj.pl/problems/MINMOVE/ On Fri, Jan 14, 2011 at 1:40 PM, snehal jain learner@gmail.com wrote: Write the code to find lexicographic minimum in a circular array, e.g. for the array BCABDADAB, the lexicographic mininum is ABBCABDAD. -- You received

Re: [algogeeks] google written

2011-01-14 Thread radha krishnan
There s O(n) solution for this :) On Fri, Jan 14, 2011 at 2:13 PM, radha krishnan radhakrishnance...@gmail.com wrote: append the string to original string and index=answer of that spoj problem now u can ouput the string from index to index+strlen(originalstring)-1 On Fri, Jan 14, 2011 at

Re: [algogeeks] google written

2011-01-14 Thread Wei.QI
FindStartIndex(char[] a) { int start = 0; int current = 1; while(current a.Length) { if(a[current] a[start]) { start = current; ++current; }else if(a[current] a[start]) { ++current; }else //a[current] ==

[algogeeks] Adobe Question

2011-01-14 Thread bittu
how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. Regards Shashank Mani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Adobe Question

2011-01-14 Thread vaibhav agrawal
are they sorted? On Fri, Jan 14, 2011 at 3:35 PM, bittu shashank7andr...@gmail.com wrote: how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space The elements are +ve in the range 0 to n power 100.. Regards Shashank Mani

Re: [algogeeks] Re: Amazon Interview - Algorithms

2011-01-14 Thread Avi Dullu
I guess u got confused with the comment I wrote, I have added 2 print statements and now I guess it should be clear to you as to why the code is O(n). The comment means that each element of the min_steps_dp will be ACCESSED only ONCE over the execution of the entire program. Hence the outer loop

Re: [algogeeks] Adobe Question

2011-01-14 Thread Ashish Goel
ideally, a hashMap would be preferred walk through one array and set the corresponding entry, and then through another array, if any entry found, then they are not disjoint. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jan 14, 2011 at

[algogeeks] Adobe Interview

2011-01-14 Thread bittu
You have N computers and [Ca, Cb] means a is connected to b and this connectivity is symmetric and transitive. then write a program which checks this Regards Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Adobe Interview

2011-01-14 Thread radha krishnan
Floyd Warshall ? On Fri, Jan 14, 2011 at 6:45 PM, bittu shashank7andr...@gmail.com wrote:  You have N computers and [Ca, Cb] means a is connected to b and this connectivity is symmetric and transitive. then write a program which checks this Regards Shashank -- You received this message

[algogeeks] Re: Adobe Interview

2011-01-14 Thread bittu
You have N computers and [Ca, Cb] means a is connected to b and this connectivity is symmetric and transitive. then write a program which checks that all computers are interconnected and talk two each other? Regards Shashank -- You received this message because you are subscribed to the Google

Re: [algogeeks] Building A Special Tree

2011-01-14 Thread Balaji Ramani
Two different binary trees can have same set of Leaves/Inner Nodes and same Preorder traversal 5 / \ 3 10 / \ 1 9 \ 7 5 / \ 3 9 / / \ 1

Re: [algogeeks] Building A Special Tree

2011-01-14 Thread vaibhav agrawal
If it is a BST...then having a pre-order traversal can give us the unique binary tree. Also, as per the problem statement, every node can have 0 or at most 2 nodes. that means every node can have 0 or two childs, which is not the case below. On Fri, Jan 14, 2011 at 6:49 PM, Balaji Ramani

Re: [algogeeks] google written

2011-01-14 Thread juver++
@qw I think you solution will timed out?! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

[algogeeks] Re: google written

2011-01-14 Thread juver++
@shehal Concatenate string to itself and then find smallest suffix of length = n -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] Re: No. of ways to Merge 2 arrays

2011-01-14 Thread Dave
@Gene: Didn't you mean (2n)! / (n!)^2 ? On Jan 13, 10:22 pm, Gene gene.ress...@gmail.com wrote: The number of ways that n things can be positioned within 2n things is 2n choose n.  This is equal to (2n!) / (n!)^2. -- You received this message because you are subscribed to the Google Groups

[algogeeks] Re: probability

2011-01-14 Thread Jammy
Bayes' theorem: http://en.wikipedia.org/wiki/Bayes'_theorem P(x=even|x3) = P(x3|x=even)*P(x=even)/P(x3)===B On Jan 14, 2:29 am, snehal jain learner@gmail.com wrote: An unbalanced dice (with 6 faces, numbered from 1 to 6) is thrown. The probability that the face value is odd is 90% of the

[algogeeks] Re: Building A Special Tree

2011-01-14 Thread Jammy
It's irrelevant but Building Special Tree has the same acronyms as Binary Search Tree...lame joke I know On Jan 14, 8:44 am, vaibhav agrawal agrvaib...@gmail.com wrote: If it is a BST...then having a pre-order traversal can give us the unique binary tree. Also, as per the problem statement,

[algogeeks] Automated Algorithm Configuration and Selection: Enabling Technologies for Building Better Algorithms

2011-01-14 Thread Ian Martin Ajzenszmidt
http://www.cs.ubc.ca/labs/beta/Projects/SATzilla/ http://www.csail.mit.edu/events/eventcalendar/calendar.php?show=eventid=2784 Automated Algorithm Configuration and Selection: Enabling Technologies for Building Better Algorithms Speaker: Frank Hutter, University of British Columbia, Vancouver

[algogeeks] Job Requirements

2011-01-14 Thread ahmed shareef
Hello Partners, Please find the requirement below and send me your available candidates.Send me the suitable resumes to ah...@gtechnologiesinc.com Position Title: Senior Architect, Information Security Architecture and Services Minimum Requirements Minimum 10+ years technical security

[algogeeks] Automated Theory Formation in Pure Mathematics by Simon Colton.

2011-01-14 Thread Ian Martin Ajzenszmidt
http://www.springer.com/computer/ai/book/978-1-85233-609-7 In recent years, Artificial Intelligence researchers have largely focused their efforts on solving specific problems, with less emphasis on 'the big picture' - automating large scale tasks which require human-level intelligence to

[algogeeks] Re: google written

2011-01-14 Thread juver++
Here is general dicsussion on this topic: http://forums.topcoder.com/;jsessionid=A92760DB520220B76858A0675626EBAC?module=ThreadthreadID=641215start=0mc=4#1100409 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Building A Special Tree

2011-01-14 Thread juver++
@balaji_ramani That is why there is additional info (L or N). So it is solvable during dfs. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send

[algogeeks] Re: Adobe Interview

2011-01-14 Thread juver++
Simple BFS or DFS solves this problem. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For

[algogeeks] Genetic and Evolutionary Computation Series by Springer

2011-01-14 Thread Ian Martin Ajzenszmidt
http://www.springer.com/series/7373?changeHeader is the source of the following. Researchers and practitioners alike are increasingly turning to search, optimization, and machine-learning procedures based on natural selection and genetics to solve problems across the spectrum of human endeavor.

[algogeeks] Automatic programming (also called program synthesis or program induction)—that is, getting computers to solve problems without explicitly programming them.

2011-01-14 Thread Ian Martin Ajzenszmidt
http://www.genetic-programming.com/johnkoza.htm Scientific Research Interests—John R. Koza Our main research interest is automatic programming (also called program synthesis or program induction)—that is, getting computers to solve problems without explicitly programming them. This goal can be

[algogeeks] Automatic programming (also called program synthesis or program induction)—that is, getting computers to solve problems without explicitly programming them.

2011-01-14 Thread Ian Martin Ajzenszmidt
http://www.genetic-programming.com/johnkoza.htm Scientific Research Interests—John R. Koza Our main research interest is automatic programming (also called program synthesis or program induction)—that is, getting computers to solve problems without explicitly programming them. This goal can be

[algogeeks] recursions

2011-01-14 Thread radha krishnan
http://zobayer.blogspot.com/2009/12/cse-102-practice-recursions.html -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] google written

2011-01-14 Thread Wei.QI
@juver++, can you give me a test case that will time out? On Fri, Jan 14, 2011 at 6:44 AM, juver++ avpostni...@gmail.com wrote: @qw I think you solution will timed out?! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] google written

2011-01-14 Thread juver++
@qw Please ignore my post. I've already removed it. Cause I found it seems to be ok. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email

Re: [algogeeks] Building A Special Tree

2011-01-14 Thread Balaji Ramani
If I am getting the question right, I believe both the above trees represent this input: 5(N) 3(N) 1(L) 9(N) 7(L) 10(L) 5 / \ 3 10 / \ 1 9 \ 7 5 / \ 3 9

[algogeeks] Re: google written

2011-01-14 Thread juver++
Here is compact linear solution (it is based on some non-trivial observations): int min = 0, p = 1, l = 0; while (p n min + l + 1 n) { int cmp = buffer[min + l] - buffer[(p + l) % n]; if (cmp == 0) ++l; else if (cmp 0) { p += l + 1; l = 0; } else {

Re: [algogeeks] Building A Special Tree

2011-01-14 Thread juver++
I thought that node has 0 or 2 childs. If so, than supplied information is enough. If node may has 1 child, then it is failed. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

[algogeeks] Re: Amazon Interview - Algorithms

2011-01-14 Thread Jammy
@Avi Greedy approach doesn't work since you can't ensure the choice is locally optimum. Consider 3,9,2,1,8,3. Using greedy alg. would give you 3,1,8,3 while otherwise DP would give you 3,9,3. On Jan 14, 6:11 am, Avi Dullu avi.du...@gmail.com wrote: I guess u got confused with the comment I

Re: [algogeeks] Re: Amazon Interview - Algorithms

2011-01-14 Thread Avi Dullu
@jammy Even I felt the same, but the greedy 'algo' u suggest is actually IMHO not a greedy approach. You just take each arr[i] and jump *without deciding a locally optimal policy* . SO, if u were to *see* arr[i] and *decide* on the optimal policy I feel one would follow d same steps as in a DP

Re: [algogeeks] Adobe Question

2011-01-14 Thread pacific pacific
Integers larger than which fit in 32/64 bits. On Thu, Jan 13, 2011 at 8:58 PM, bittu shashank7andr...@gmail.com wrote: 1. 10 test cases for entering 3 values representing sides of a triangle and the program giving output as scalene, isosceles or equilateral--Means At Least 10

Re: [algogeeks] google paper/...plz help..its urgent

2011-01-14 Thread pacific pacific
On Wed, Jan 12, 2011 at 2:44 PM, snehal jain learner@gmail.com wrote: 1. Quick-sort is run on two inputs shown below to sort in ascending order (i) 1,2,3, ….,n (ii) n, n - 1, n - 2, …., 2, 1 Let C1 and C2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,

Re: [algogeeks] Re: Amazon Interview - Algorithms

2011-01-14 Thread pacific pacific
At each location if the value is k , find the largest value in the next k elements and jump there. This greedy approach works in 0(n^2) and i believe it works. If not can someone give me a counter example ? On Sat, Jan 15, 2011 at 3:30 AM, Avi Dullu avi.du...@gmail.com wrote: @jammy Even I

[algogeeks] Re: Amazon Interview - Algorithms

2011-01-14 Thread SVIX
@pacific.. the approach needs a little bit of tuning... for instance, for the set 9 8 7 6 5 4 3 2 1 1 2, per ur approach, u will pick 9, 8, 7, 6 etc... minimum jumps in reality is from 9 to 1 to 2. On Jan 14, 8:19 pm, pacific pacific pacific4...@gmail.com wrote: At each location if the value

Re: [algogeeks] Building A Special Tree

2011-01-14 Thread Decipher
@balaji - In the first tree , 9 has one only child which is not possible for this question. @juver++ - Can you give some algo for this problem -- 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] ThreeListSum

2011-01-14 Thread Puneet Ginoria
Sorry.. u need 2 sort only one array. whichever u likei was thinking to sort 1 array and wrote to sort all 3 anyway ... sort only one On Tue, Jan 11, 2011 at 1:18 PM, MOHIT mohit...@gmail.com wrote: @ puneet then we have to sort only one array, on which we doing binary search

Re: [algogeeks] Re: Find The Looping Node

2011-01-14 Thread Shachin Sharma
@ snehal I have a doubt. Are you sure this will terminate and find the looping node? slow1=head; while( slow1!=slow) { prev=slow; slow=slow-next; slow1=slow1-next; } Consider this example list with nodes 1-12 looping node 5. 1 2 3 4 5 6 7 8 - |

Re: [algogeeks] Building A Special Tree

2011-01-14 Thread juver++
@Decipher - something like this: void build_tree(Node* node, int index) { node = new Node(value[index++]); // create an empty node if (label[index] == 'L') return; // we are at leaf, there is no need to process further current subtree build_tree(node-left, index); // build left and right