Re: [algogeeks] Finding intersection of 2 linked lists

2012-07-05 Thread Ashish Goel
struct node* intersection( struct node *pL1, struct node* pL2) { if ((!pL1) || (!pl2)) return NULL; struct node * pL3 = NULL; struct node* pL3Tail = NULL; while(pL1)(pL2) { if (pL1-data pL2-data) pL1=pL1-next; else if (pL1-data pL2-data) pL2=pL2-next; else { struct

Re: [algogeeks] Finding intersection of 2 linked lists

2012-07-05 Thread Abhishek Sharma
@nishant, you wrote until both the distance becomes equal.Which distances ? Could you please elaborate ? On Thu, Jul 5, 2012 at 12:52 PM, Ashish Goel ashg...@gmail.com wrote: struct node* intersection( struct node *pL1, struct node* pL2) { if ((!pL1) || (!pl2)) return NULL; struct node

Re: [algogeeks] Finding intersection of 2 linked lists

2012-07-05 Thread adarsh kumar
Hope the following will be of help: http://www.geeksforgeeks.org/archives/18615 regds. On Thu, Jul 5, 2012 at 4:32 PM, Abhishek Sharma abhi120...@gmail.comwrote: @nishant, you wrote until both the distance becomes equal.Which distances ? Could you please elaborate ? On Thu, Jul 5, 2012 at

Re: [algogeeks] Finding intersection of 2 linked lists

2012-07-05 Thread Nishant Pandey
both the distance means distance between the two linked list some thing like this : struct node *temp1,*temp2; temp1 = head1; temp2 = head2; int l1 = get_dist(head1); int l2 = get_dist(head2); int ds = abs(l1-l2); if( l1 l2 ) { for(int i=0;ids;i++) {

Re: [algogeeks] MS Design Ques

2012-07-05 Thread Anshu Mishra
First define all the basic operation you can apply on two numbers. Binary operation : +, -, *, /, %, optional((and), |(or), ^(xor)) Unary operation : !, ~, - Comparison : , ==, != Define all these operation. Most simplest one can be, class BIG_INT { private string val; //Define

Re: [algogeeks] MS Design Ques

2012-07-05 Thread payal gupta
thnx...4 d rply.. Regards, PAYAL GUPTA, NIT-B. On Fri, Jul 6, 2012 at 12:43 AM, Anshu Mishra anshumishra6...@gmail.comwrote: First define all the basic operation you can apply on two numbers. Binary operation : +, -, *, /, %, optional((and), |(or), ^(xor)) Unary operation : !, ~, -

[algogeeks] Re: Finding intersection of 2 linked lists

2012-07-05 Thread himanshu tyagi
here is a recursive method. First sort the two list and use the following algo. initial value of third parameter is NULL. struct node *sortedIntersect(struct node *a, struct node *b, struct node *result) { /* base case */ if(a == NULL || b == NULL) {

[algogeeks] Re: Finding intersection of 2 linked lists

2012-07-05 Thread himanshu tyagi
here is an recursive method the two linked list have to be in sorted order. struct node *sortedIntersect(struct node *a, struct node *b, struct node *result) { /* base case */ if(a == NULL || b == NULL) { return NULL; } /* If both

[algogeeks] Re: Write a C program to reconstruct a BST from a given array of preorder traversal.

2012-07-05 Thread Zyro
@Navin : Why r u sorting the array .. BST can be made using the preorder traversal if null nodes are well defined in the given traversal.. Right?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: Write a C program to reconstruct a BST from a given array of preorder traversal.

2012-07-05 Thread Zyro
?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/HQ_TvoKSLNgJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

[algogeeks] Re: simple FILE reading problem.

2012-07-05 Thread Zyro
@Navin : Read a line .. store it in a string .. then extract numbers frm it.. It will be more faster i think.. :) On Wednesday, 4 July 2012 22:44:04 UTC+5:30, Navin Kumar wrote: Suppose a file.txt contains : 50 40 30 # # 5 # 10 # # i want to fetch only integers. How should i fetch it. I

[algogeeks] Most compatible people

2012-07-05 Thread enchantress
Given a list of people and music bands they like, two people are compatible if they have at least 2 bands in common. The compatibility of two people is directly proportional to the number of bands they like in common. Find the two most compatible people that is having maximum number of bands