[algogeeks] Re: Automaton

2006-01-18 Thread pramod
I don't think so. Let the odd number be AnAn-1An-2...A3A2A1. This number can be odd, if AnAn-1...A3A2 is odd and A1 is even (0/2) OR AnAn-1...A3A2 is even and A1 is odd (1). So this clearly gives a simple DFA. let Qs be the start state and Qe is the state DFA enters when an even number is seen

[algogeeks] Re: Abacus Online Programming Contest - January 29th

2006-01-18 Thread Mattia Merzi
On 1/18/06, Karthik Singaram L [EMAIL PROTECTED] wrote: [...] Time of submission therefore has a higher priority therefore. that was my point, in fact ... I (personally) don't agree with this rule ... Well, I understand that a time limit must be set, I can't say well, ok, I will finish until

[algogeeks] Re: Abacus Online Programming Contest - January 29th

2006-01-18 Thread Prunthaban Kanthakumar
Inmost of the good opcs(Including Abacus)only the best code survives the tests! You can't write bubble sort when asked for a sorting algorithm! It will simply time out! So provided only the best algo survives, the next criteria for evaluation will obviously be How quick u came out with the idea

[algogeeks] Re: Typical Interesting questions

2006-01-18 Thread Mattia Merzi
On 1/18/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Given k sorted streams where each stream could possibly be infinite in length, describe an efficient algorithm to merge the k streams into a new stream (also in sorted order). // assuming that you sort from the lowest to the highest value

[algogeeks] Re: Typical Interesting questions

2006-01-18 Thread Arunachalam
For the question 2, What to do you mean by Inverting tree? Are you talking of the mirror image. If so you dont have to make two recursive calls. You can call only for left child recusively. And since this is a tail recursion ,you can convert into a iterative solution easily. I dont think any

[algogeeks] Re: Typical Interesting questions

2006-01-18 Thread Hemanth
Hey Mattia, Say n is the total number of elements in all the streams put together. The time complexity of your solution is O(n * k). Since you see every element once and k-1 comparisons are required in the worst case to find the smallest element. This approach is actually fine if the streams