Re: [algogeeks] Re: [Directi] Two most distant element in tree

2012-03-26 Thread atul anand
@Don : it seem that you are calculating diameter of a tree ?? On Mon, Mar 26, 2012 at 7:18 PM, Don wrote: > If the longest path passes through the root of the tree, then the > length of the path is the depth of the left subtree plus the depth of > the right subtree. If the longest path does not

Re: [algogeeks] Re: [Directi] Two most distant element in tree

2012-03-26 Thread shady
@arunachalam you have misunderstood the problem. On Tue, Mar 27, 2012 at 8:10 AM, Arunachalam wrote: > This algorithm is almost right, but not exactly correct. > > Say for example you have a binary tree like this > >1 > 2 >3 4 > 5 6 > > The

Re: [algogeeks] Slang Decoder chatBot... give a try...

2012-03-26 Thread amrit harry
@Andreas i used XAMPP protocol to connect and designed this using PHP i hardcode only those keywords that i know... it would be my pleasure if you help me to expand library. Thanks. Contact me @ dabbcomput...@gmail.com On Tue, Mar 27, 2012 at 9:34 AM, atul anand wrote: > i had made similar gtalk

Re: [algogeeks] Google Question Invoice -bills

2012-03-26 Thread atul anand
@ankush: i told one approach above , but may i want clear . i am not saying this is the best approach to do so but it is one naive soln i came up with. so find all possible combination for each invoice and save it in some data structure. now start from 1st invoice and select 1st invoice combinatio

Re: [algogeeks] Slang Decoder chatBot... give a try...

2012-03-26 Thread atul anand
i had made similar gtalk long time back...but it was for chatting and has gtalk look alike gui interface but more colorful :P . i had used smack library. most of the text chatting application uses xmpp protocol. On Tue, Mar 27, 2012 at 2:24 AM, Andreas Hahn wrote: > Hi, > > I've tested your slang

Re: [algogeeks] Need help regarding threads

2012-03-26 Thread SAMM
Yaa Senthil is right , I overlooked it . In 3rd argument also it is expecting an address while u r passing the pointer . -- 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 unsub

Re: [algogeeks] Re: [Directi] Two most distant element in tree

2012-03-26 Thread Arunachalam
This algorithm is almost right, but not exactly correct. Say for example you have a binary tree like this 1 2 3 4 5 6 The length of the longest path is 4, and this algorithm would return 5. The algorithm can be slightly modified to find the m

Re: [algogeeks] Need help regarding threads

2012-03-26 Thread Senthil Nathan
The problem is with the third argument in *pthread_create(&thread1,NULL,(void*)sender,(void*)0);* * * It should just be sender or &sender. *pthread_create(&thread1,NULL,sender,(void*)0);* Thanks, Senthil. On Mon, Mar 26, 2012 at 5:25 PM, Sagar Pareek wrote: > Hello all, > I need help regardin

Re: [algogeeks] Slang Decoder chatBot... give a try...

2012-03-26 Thread saurabh singh
My impression is that the author is using http://www.imified.com/ or a similar platform which provides an interface to g-talk via very simple PHP.The bad news is though that imified is going to be shut down soon as they are not earning profit in this plan. Saurabh Singh B.Tech (Computer Science) M

Re: [algogeeks] Need help regarding threads

2012-03-26 Thread SAMM
I think is error is in the 4th argument u r passing in this line * pthread_create(&thread1,NULL,(void*)sender,(void*)0);* The 4th argument is expecting the address of the arguments , but the address he is getting is 0 , which is not granted by OS . Tht address is used by OS I guess . Instead* (voi

[algogeeks] Need help regarding threads

2012-03-26 Thread Sagar Pareek
Hello all, I need help regarding thread implementation in C++ Here is my sample code... *class TraCISagar : public BasicModule1 { public: . . void activity(); void* sender(void*); . . }; void* TraCISagar::sender(void* a) { . . . } void TraCISagar::activity()

Re: [algogeeks] Slang Decoder chatBot... give a try...

2012-03-26 Thread Andreas Hahn
Hi, I've tested your slang decoder bot and my first impression is: nice work, well done =) Unfortunetely the slang decoder's vocabulary isn't very big and most of the times I tested some exotic abbreviations, it just echoed my input =). But anyway, nice work. If you would like to expand the vocab

[algogeeks] Re: Google Question Invoice -bills

2012-03-26 Thread Don
If there is a way to do this in polynomial time I would like to see it. Don On Mar 26, 3:04 am, Ankush Bagotra wrote: > There are 210 Invoices and 1700 bills – these bills add up to these invoices > > The association between  bills and invoices is lost . The only way to > match them is by adding

[algogeeks] Re: MS QUESTION_LINKED LIST

2012-03-26 Thread Don
To merge sort a linked list, do the following: Make log n passes through the list. In each pass, combine each adjacent pair of smaller sorted lists into one larger sorted list. Each pass is O(n), and doubles the length of the sorted lists. Thus, after log n passes, the list of n items is sorted. Fo

Re: [algogeeks] MS QUESTION_LINKED LIST

2012-03-26 Thread Harjot singh
@atul anand: the question simply says that in each node the second should point to the next larger no. which means in your case 7 3 5 1 5 9 the output should be 7->9 5->7 3->5 1->3 On Mon, Mar 26, 2012 at 10:37 AM, Dheeraj Sharma < dheerajsharma1...@gmail.com> wrote: > Correct me if am wrong.. i

[algogeeks] Re: [Directi] Two most distant element in tree

2012-03-26 Thread Don
If the longest path passes through the root of the tree, then the length of the path is the depth of the left subtree plus the depth of the right subtree. If the longest path does not pass through the root, then it is the max of the longest path in the left subtree or the right subtree. int longes

Re: [algogeeks] Re: POW function in C++/C

2012-03-26 Thread shady
@don it is, actually i wanted to give a smaller example so wrote like that. @arpit thanks, powl() solved the problem. On Mon, Mar 26, 2012 at 7:00 PM, Don wrote: > Why use pow to compute a square when * is significantly faster? > Don > > On Mar 26, 6:09 am, shady wrote: > > Hi, > > i am using

[algogeeks] Re: POW function in C++/C

2012-03-26 Thread Don
Why use pow to compute a square when * is significantly faster? Don On Mar 26, 6:09 am, shady wrote: > Hi, >  i am using pow() function in C++ to calculate square of 99937, but to > my amazement it is giving one less than actual value. Since it returns > double, i am adding 10e-5 to get the c

Re: [algogeeks] Google Question Invoice -bills

2012-03-26 Thread ankush . bagotra
You can use dp to find subsets . But how is dp used for the overall probkem Sent from BlackBerry® on Airtel -Original Message- From: atul anand Sender: algogeeks@googlegroups.com Date: Mon, 26 Mar 2012 16:52:08 To: Reply-To: algogeeks@googlegroups.com Subject: Re: [algogeeks] Google Qu

Re: [algogeeks] POW function in C++/C

2012-03-26 Thread Arpit Sood
use powl() On Mon, Mar 26, 2012 at 4:39 PM, shady wrote: > Hi, > i am using pow() function in C++ to calculate square of 99937, but to > my amazement it is giving one less than actual value. Since it returns > double, i am adding 10e-5 to get the correct value, but still no > improvement. A

Re: [algogeeks] Google Question Invoice -bills

2012-03-26 Thread atul anand
@umer : dp approach is given in above post. On Mon, Mar 26, 2012 at 4:11 PM, Umer Farooq wrote: > Well, they have specified in the question that "you are dealing with > big-data sets". So, recursion won't be a good option I guess. > > Can we solve it with dynamic programming technique? > > > On

[algogeeks] POW function in C++/C

2012-03-26 Thread shady
Hi, i am using pow() function in C++ to calculate square of 99937, but to my amazement it is giving one less than actual value. Since it returns double, i am adding 10e-5 to get the correct value, but still no improvement. Any idea ? -- You received this message because you are subscribed to

Re: [algogeeks] Google Question Invoice -bills

2012-03-26 Thread Umer Farooq
Well, they have specified in the question that "you are dealing with big-data sets". So, recursion won't be a good option I guess. Can we solve it with dynamic programming technique? On Mon, Mar 26, 2012 at 2:24 PM, atul anand wrote: > one way to do it , is say first combination for invoice 80=

Re: [algogeeks] Google Question Invoice -bills

2012-03-26 Thread atul anand
one way to do it , is say first combination for invoice 80= 50 + 30 now remove 80 and 30 from the input bills while finding combination from 210 , check if it is possible if yes , we got one solution not select another invoice combination 80= 50 + 10 + 20 now dont consider these values while find c

Re: [algogeeks] Google Question Invoice -bills

2012-03-26 Thread Ankush Bagotra
Ok now you have combination of each invoice . What is the approach to take mutual exclusive combinations for so that sum of all bills equals sum of all invoices On Mon, Mar 26, 2012 at 2:16 PM, atul anand wrote: > it is similar to sum-subset problem following recurrance will solve this > problem

Re: [algogeeks] Google Question Invoice -bills

2012-03-26 Thread atul anand
it is similar to sum-subset problem following recurrance will solve this problem , you need to run algo for each invoice to find all combination F(n,k) = F(n,k-1) or F(n - a[k], k-1) base case :F(0,k)=1 for k>=0 F(n,0)= 0 for n>0. On Mon, Mar 26, 2012 at 1:34 PM, Ankush Ba

Re: [algogeeks] Amazon Onsite

2012-03-26 Thread Arpit Sood
@ankur +1 correct algo, can be done in just one pass. On Mon, Oct 24, 2011 at 11:03 PM, Ankur Garg wrote: > I think this can be solved like this . > Start from the first petrol pump i.e first point in the circle . Now if > the petrol finishes befor reaching the second petrol pump that means we >

[algogeeks] Google Question Invoice -bills

2012-03-26 Thread Ankush Bagotra
There are 210 Invoices and 1700 bills – these bills add up to these invoices The association between bills and invoices is lost . The only way to match them is by adding them up to correct amounts that are equal to the invoices. For Example : there were 2 invoices for 80, 210 and you have bills

Re: [algogeeks] [Directi] Two most distant element in tree

2012-03-26 Thread shady
bfs/dfs will work but will be complex. First do a BFS from root node, and reach a corner(leaf node). This node will always be the part of solution, so you will do another BFS from this leaf node. For this you need to store for every node their parent and child pointers. @lucifier +1 On Sun, Mar