Re: [algogeeks] random function

2010-12-27 Thread DIPANKAR DUTTA
read modeling and simulation book it has a great discussion on random number generartion and testing On Mon, Dec 27, 2010 at 11:52 AM, 王大东 dadongk...@gmail.com wrote: Linear congruential sequence maybe a simple approach. A[n]=(a*A[n-1]+b)%c, But it's another problem how to chose a,b,c. On

[algogeeks] Re: 1s and 0s

2010-12-27 Thread awesomeandroid
your first approach is totally correct. On Dec 22, 12:36 pm, juver++ avpostni...@gmail.com wrote: Use bits manipulation tricks. 1. There is a way to remove a group of consecutive 1's from the right: A = n (n + 1). Then check if A==0 then OK. 2. Second approach: B=n+1, check if B (B-1) (this

Re: [algogeeks] Re: Interview question

2010-12-27 Thread juver++
Program is incorrect. Why does it output the following answer: point at (3,5 )size is 8??? -- 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

Re: [algogeeks] Amazon Question

2010-12-27 Thread mohit ranjan
interested ppl can read ths link for stream algorithms... http://www.americanscientist.org/issues/pub/the-britney-spears-problem/1 Mohit On Sun, Dec 26, 2010 at 7:49 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: may be we can assume that klog(n) else i dont see a way out than hashing ,

Re: [algogeeks] Re: convert binary matrix to zero matrix

2010-12-27 Thread Terence
when you are talking abt starting from 1 that means that array is 1 based , right ? Right. 111 000 000 Up-left element: 1 Choice 3: 0 (number of 0's on the first row) + 1 (number of 1's on the first column) = 1 Choice 4: 3 (number of 1's on the first row) + 2 (number of 0's on the first

Re: [algogeeks] 10 Most Frequent Search Text

2010-12-27 Thread DIPANKAR DUTTA
hey... what's about the storage managment ? the search text may not be a fixed length string.. is implementation of a node is fessible? one alternative solution may be associate a hash table along with this. but again the problem with collision ,, to avoid collision u can use perfect hashing with

[algogeeks] Re: Simulation algo

2010-12-27 Thread Glauben
Hello , Sorry :( Chi i can not help you , i don't know that algorithm . All the best . On 26 déc, 20:10, Chi i...@chihoang.de wrote: Hi, I'm looking for the fleury or the hierholzer algorithm in php, c or fleury. Do u can help? Perhaps u can take a look at bin-packing algorithm and

Re: [algogeeks] 10 Most Frequent Search Text

2010-12-27 Thread Chi
Thank u for reading. My kart-trie is between a radix-trie and suffix-trie because a radix-trie can also have as many leafs as suitable and a suffix-trie also. A kart-trie has exactly 2 leafs per node. Correct me if I'm wrong! - Ursprüngliche Mitteilung - hey... what's about the

Re: [algogeeks] 10 Most Frequent Search Text

2010-12-27 Thread Abhinav
This can be done in O(n ) with O(1) space compexity . This problem can be reduced to finding the kth smallest number in an unordered collection . There exists an O(n) algo for this . For finding the 10th most frequent number we should find (n-10)th smallest number . Once found by doing an linear

Re: [algogeeks] Re: Pythagorean triples

2010-12-27 Thread Akash Agrawal
http://tech-queries.blogspot.com/2010/12/find-pythagorean-triples-in-unsorted.html Regards, Akash Agrawal http://tech-queries.blogspot.com/ On Mon, Dec 20, 2010 at 8:12 PM, Dave dave_and_da...@juno.com wrote: Unless sorting the array is forbidden, sort it and then use the obvious O(n^2)

Re: [algogeeks] Google Interview Question

2010-12-27 Thread Anand
@Terence. Could please elaborate your answer. Bottom up level order traversal helps to get the final root value but how to use it to find minimum flips needed to Obtain the desired root value. On Fri, Dec 24, 2010 at 1:56 AM, Terence technic@gmail.com wrote: Using the same level order

[algogeeks] arrays

2010-12-27 Thread Anand
I have a two arrays One is 2 5 1 6 4 3 other is 1 2 3 4 5 6. I want to make an array X which gives the index of its element on other arrays. Meaning X[1] = 3 1 is element of the second array and 3 is the index of element 1 in first array. How shall we get array X in O(nlogn). -- You

Re: [algogeeks] Google Interview Question

2010-12-27 Thread pacific pacific
here is my approach : Starting from the root node , if root node need to have a 1 ... if root is an and gate : flips = minflips for left child to have value 1 + minflips for the right child to have value 1 else flips = minimum of ( minflips for left child to have value 1 , minflips for

[algogeeks] Re: Google Interview Question

2010-12-27 Thread suhash
This problem can be solved using dp in O(n), where 'n' is the number of nodes in the tree. Definitions: Let gate[i] be a boolean denoting whether the gate at node 'i' is 'AND' or 'OR'. (0-'AND' 1-'OR') Let dp[i][j] store the minimum no. of swaps required to get a value of 'j' (0 or 1), for the

[algogeeks] Re: Google Interview Question

2010-12-27 Thread suhash
Your approach is for a binary tree, but the problem statement does not say anything about it. On Dec 28, 10:27 am, pacific pacific pacific4...@gmail.com wrote: here is my approach : Starting from the root node , if root node need to have a 1 ... if root is an and gate :      flips  =

[algogeeks] Re: SUN Microsystem Question

2010-12-27 Thread Gene
It would be interesting to do some tests. Asymptotic performance isn't always important. It's possible that since we are looking for only the top 10 elements, we'll get better run times using a simple linear scan to find the insertion point (as in insertion sort) rather than the more complex