[algogeeks] Re: whether 2 lists produce identical BST's or not?

2006-11-02 Thread Arun
i think either me or u have misunderstood the problem.> A list can be transformed to serveral BSTs A list will give only one BST. (First node is always root). There is only one way of consrtucting a BST. Isnt it? Again this will be badly balanced depending the order of elements in the list. > And I

[algogeeks] Re: whether 2 lists produce identical BST's or not?

2006-11-02 Thread Arun
Hi, the ones u mentioned are by property of BST. The original problem imposes a constraint on building the BST, so the recursive sol'n maynot work :)On 11/2/06, Arunachalam <[EMAIL PROTECTED]> wrote: Here are my interesting observations   1) The first element of the BST will remain as the root. 2)

[algogeeks] Re: majority element

2006-11-02 Thread ericunfuk
Arunachalam wrote: > Search the groups, this problem is already solved in O(n) time in the > groups. > > regards > Arunachalam. I solved it with n/2 case, I dont see how to do that with n/t, t arbitrary. Thanks --~--~-~--~~~---~--~~ You received this message be

[algogeeks] Re: Random String Generation

2006-11-02 Thread Arunachalam
Look at one way hashing algorithms. Which can map a password to some byte keys.   I think MD5 will solve your purpose. But collisions are possible in MD5. http://en.wikipedia.org/wiki/MD5   regards Arunachalam.  On 11/2/06, howa <[EMAIL PROTECTED]> wrote: Hi geek, consider the following suitation..

[algogeeks] Re: majority element

2006-11-02 Thread Arunachalam
Search the groups, this problem is already solved in O(n) time in the groups.   regards Arunachalam.  On 11/2/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: It seems that you gotta use the "median" algrithm. Here's some ideawithout implementation, I wish it will help. if the array has an odd numb

[algogeeks] Re: whether 2 lists produce identical BST's or not?

2006-11-02 Thread Arunachalam
Here are my interesting observations   1) The first element of the BST will remain as the root. 2) All the elements which are smaller than the root will go to the left of the root node. 3) All the elements greater would go to the right of the root node.   Right tree and left tree should be tested r

[algogeeks] Re: Cryptarithmetic problems

2006-11-02 Thread Lego Haryanto
A "quicker" brute force (not the one with 10! complexity) is by doing a recursion starting from the rightmost digit.   The number of levels in the recursion is the same as the longest digits (in the sample case: 5, which is length of MONEY).  After we processed 5 levels, we know we got a solution.

[algogeeks] Cryptarithmetic problems

2006-11-02 Thread Rave Hanker
Hello, I was asked this in my ICPC qualifiers. Are there any good algorithms to solve Cryptarithmetic problems http://en.wikipedia.org/wiki/Send%2Bmore%3Dmoney   like SEND+MOREMONEYwhere each character should be assigned a unique digit.One more constraint i got was to sort the answer by

[algogeeks] Random String Generation

2006-11-02 Thread howa
Hi geek, consider the following suitation... 1. a server, response to incoming users with a random generated string (less than 255 bytes) 2. a user, might request to a server at the same time, i.e. within the same second of time 3. within a second, the requests might be as high as 1000 4. the

[algogeeks] Re: majority element

2006-11-02 Thread [EMAIL PROTECTED]
It seems that you gotta use the "median" algrithm. Here's some idea without implementation, I wish it will help. if the array has an odd number of lements, then the array can be devided into 3 parts: Head, Median, Tail If an element occurs more than n/m times, then at least in Head or in Tail it

[algogeeks] Re: whether 2 lists produce identical BST's or not?

2006-11-02 Thread [EMAIL PROTECTED]
A list can be transformed to serveral BSTs (If the number of elements is n, then you can caculate the numbers of its BSTs). But, if we chose a specified method or process (just as ravi supposed) to construct the BST, then it will be unique. I have the same opinion with Vijendra Singh. He said "I

[algogeeks] Re: whether 2 lists produce identical BST's or not?

2006-11-02 Thread arun kumar manickan
Hi,     We can make the following observations : 1) Both arrays A and B should have same no of elements 2) First element of both A and B should be the same 3) All elements less than the first element in array A should come in the same order in array B also. 4) All elements less than the second elem

[algogeeks] Re: majority element

2006-11-02 Thread Arun
hash table :)if u dont like O(n) space, a st.forward approach is sorting. this will take of any value of m, but ofcourse O(nlgn) time On 11/1/06, ericunfuk <[EMAIL PROTECTED]> wrote: Dear all,I have worked out the following algorithm for finding the majorityelement(the element occurs more than n/2

[algogeeks] Re: whether 2 lists produce identical BST's or not?

2006-11-02 Thread Arun
> In fact, if two lists have identical elements, they have identical BST sets. this is not correct. its order sensitive. if u see his example L1 and L3 cannot be simply compared like strings. There can be many ways to have the same elements given in slightly different order yet produce the same BST

[algogeeks] Re: whether 2 lists produce identical BST's or not?

2006-11-02 Thread [EMAIL PROTECTED]
:). Apparently, Ravi has an assumption that each BST should be constructed with same method. And the first one is choosen as a root. In fact, if two lists have identical elements, they have identical BST sets. At least, if we focus on Ravi's problem, this problem will be reduced to order compari