[algogeeks] Re: Longest Path in A Graph

2012-02-23 Thread Krishna Kishore
Thank You very much friends. I ve read algorithm Topological Sorting. First we have to perform the topological sorting ( in Linear Time ) on the graph. Then we can find which is the Longest Path in that ordering. But it works for only DAG ( Directed Acyclic Graphs ). I ve done it. But after perform

Re: [algogeeks] Re: merge two sorted list

2012-02-23 Thread Ashish Goel
tails needs to be updated in while loop also Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Thu, Feb 23, 2012 at 8:19 PM, Don wrote: > // Iterative merge > struct node* SortedMerge(struct node* a, struct node* b) > { > struct node* head, tai

[algogeeks] Re: merge two sorted list

2012-02-23 Thread Don
Is the desired behavior to remove duplicates? On Feb 23, 5:14 am, "Karthikeyan V.B" wrote: > Hi, > > this logic generates 10 10 20 25 .. and so on it doesn delete the > duplicates in the result list -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks"

Re: [algogeeks] merge two sorted list

2012-02-23 Thread atul anand
output is 10 10 20 25 30 On Thu, Feb 23, 2012 at 4:44 PM, Karthikeyan V.B wrote: > Hi, > > this logic generates 10 10 20 25 .. and so on it doesn delete the > duplicates in the result list > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" grou

[algogeeks] Re: merge two sorted list

2012-02-23 Thread Don
// Iterative merge struct node* SortedMerge(struct node* a, struct node* b) { struct node* head, tail; // Select first node if (a->data < b->data) { head = tail = a; a = a->next; } else { head = tail = b; b = b->next; } // Merge lists while(a && b) { if (

[algogeeks] Re: merge two sorted list

2012-02-23 Thread Don
Why are you using tail recursion when an iterative approach would be more efficient? Don On Feb 23, 3:41 am, rahul sharma wrote: > struct node* SortedMerge(struct node* a, struct node* b) > { >   struct node* result = NULL; > >   /* Base cases */ >   if (a == NULL) >      return(b); >   else if (

Re: [algogeeks] merge two sorted list

2012-02-23 Thread Karthikeyan V.B
Hi, this logic generates 10 10 20 25 .. and so on it doesn delete the duplicates in the result list -- 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 gro

Re: [algogeeks] Maximize XOR

2012-02-23 Thread Dipit Grover
http://discuss.joelonsoftware.com/default.asp?interview.11.614716 -- 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+unsubs

[algogeeks] Maximize XOR

2012-02-23 Thread sunny agrawal
Given an array of N integers, Find two Numbers with max XOR value. Naive Algorithm is O(N^2), what can be a better approach ? -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geek

Re: [algogeeks] Amazon written test question

2012-02-23 Thread HARISH S.C
Hi, Construct a BST with 2,1,3. If my understanding is right, now distance between 2,3 will be 2. Will this algo return the correct answer?. On Thu, Feb 2, 2012 at 1:43 PM, Manni mbd wrote: > Forget my previous post. it useless i think > Firstly there will be only 1 node upwards which will be