[algogeeks] Re: coloring (Marking)

2009-10-09 Thread Raghavendra Sharma
Find the minimum spanning tree. Find the nodes with indegree of 1 and mark the node which connects to that node with indgree 1. On Wed, Oct 7, 2009 at 11:08 PM, Ramaswamy R ramaswam...@gmail.com wrote: We have to find the minimum cardinality out of all possible bi-partite sets of the graph.

[algogeeks] Re: coloring (Marking)

2009-10-09 Thread Miroslav Balaz
LOL search for dominance in graph. 2009/10/7 ankur aggarwal ankur.mast@gmail.com Given a graph.. Find the minimum number of coloring (Marking) required to node such that every node in the final graph is connected by at least one of the colored(marked) node. ex: AB AC BD BE CF

[algogeeks] sum of subsequence.

2009-10-09 Thread ankur aggarwal
2. Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. i) 3 2 7 10 should return 13 (sum of 3 and 10) ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)

[algogeeks] Y shaped linklist

2009-10-09 Thread ankur aggarwal
How to find the intersection point in linked list with the following constraints 1) one traversal for each of the lists 2) should not find the LENGTH of the lists 3) can USE recursion It goes like this ... --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] infinite memory

2009-10-09 Thread ankur aggarwal
How will you implement infinite memory(infinite strings) in finite space Propose some method... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] search your friend

2009-10-09 Thread ankur aggarwal
You are standing at a crossing from where there emerge four roads extending to infinity. Your friend is somewhere on one of the four roads. You do not know on which road he is and how far he is from you. You have to walk to your friend and the total distance traveled by you must be at most a

[algogeeks] Re: Y shaped linklist

2009-10-09 Thread sharad kumar
hash one list and wen u traverse other check if prest in hash On Fri, Oct 9, 2009 at 10:02 AM, ankur aggarwal ankur.mast@gmail.comwrote: How to find the intersection point in linked list with the following constraints 1) one traversal for each of the lists 2) should not find the LENGTH

[algogeeks] Re: sum of subsequence.

2009-10-09 Thread nikhil garg
This is a simple dp problem . define for each i following 2 quantities : best1[i] : best sum in similar constraint of first i elements only when last ( ith ) term is always included best2[i] : best sum in similar constraint of the first i elements only when last (ith ) term is NOT included so we

[algogeeks] Re: sum of subsequence.

2009-10-09 Thread sharad kumar
#includeiostream using namespace std; int maxsum(int a[], int n) { int prevmaxsum=0; int currmaxsum=a[0]; int last=0,temp=0; for(int i=1;in;i++) { if(last!=(i-1)) { prevmaxsum=currmaxsum; currmaxsum=a[i]+prevmaxsum; last=i;

[algogeeks] Re: sum of subsequence.

2009-10-09 Thread Debanjan
On Oct 9, 8:56 am, ankur aggarwal ankur.mast@gmail.com wrote: 2. Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array.  i) 3 2 7 10 should return 13 (sum of

[algogeeks] Re: Y shaped linklist

2009-10-09 Thread ankur aggarwal
@sharad wat about space ?? extra space ? --~--~-~--~~~---~--~~ 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

[algogeeks] Re: coloring (Marking)

2009-10-09 Thread ankur aggarwal
it is NP hard problem i suppose.. On Fri, Oct 9, 2009 at 4:20 PM, Miroslav Balaz gpsla...@googlemail.comwrote: LOL search for dominance in graph. 2009/10/7 ankur aggarwal ankur.mast@gmail.com Given a graph.. Find the minimum number of coloring (Marking) required to node such that

[algogeeks] Re: Y shaped linklist

2009-10-09 Thread sharad kumar
space comp O(n) time o(2n) both in terms of worst case On Fri, Oct 9, 2009 at 8:46 PM, ankur aggarwal ankur.mast@gmail.comwrote: @sharad wat about space ?? extra space ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to

[algogeeks] Re: search your friend

2009-10-09 Thread Dave
Wouldn't it be better to replace step 5 with Travel 2^(n+1) distance on the fourth road. If you find your friend DONE else return back to the crossing ? After you have exhausted the first three roads to a distance 2^n, there is no point to going only 2^n on the fourth road and then returning

[algogeeks] Re: search your friend

2009-10-09 Thread anilkumarmyla
Anyway the solution is O(d) [:)] which is asked to be proved. --~--~-~--~~~---~--~~ 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

[algogeeks] Re: Y shaped linklist

2009-10-09 Thread sandeep jain
Here is one solution http://geeksforgeeks.org/?p=2405 On Fri, Oct 9, 2009 at 9:00 AM, sharad kumar aryansmit3...@gmail.comwrote: space comp O(n) time o(2n) both in terms of worst case On Fri, Oct 9, 2009 at 8:46 PM, ankur aggarwal ankur.mast@gmail.comwrote: @sharad wat about space

[algogeeks] Re: search your friend

2009-10-09 Thread ankur aggarwal
yes anil your approach is rite.. --~--~-~--~~~---~--~~ 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] balls and lines

2009-10-09 Thread ankur aggarwal
Given 13 balls, how would you arrange them in 9 lines, such that there are 4 balls in each line? You can assume that the lines are arranged in 2-D space and that a ball cannot be placed on top of another ball. Bonus: if you find that too easy, and have loads of time to kill, then how about

[algogeeks] n balls and k different colors 1=k=n

2009-10-09 Thread vicky
u have to color n similar balls with k diff. colors , such that every color must be used atleast once find the no. of ways --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: n balls and k different colors 1=k=n

2009-10-09 Thread vicky
example: n=10,k=10 ans:1 n=30,k=7 ans: 475020 On Oct 10, 9:51 am, vicky mehta...@gmail.com wrote: u have to color n similar balls with k diff. colors , such that every color must be used atleast once find the no. of ways --~--~-~--~~~---~--~~ You received this

[algogeeks] Re: n balls and k different colors 1=k=n

2009-10-09 Thread Prunthaban Kanthakumar
Sterling numbers of second kind. On Sat, Oct 10, 2009 at 10:41 AM, vicky mehta...@gmail.com wrote: example: n=10,k=10 ans:1 n=30,k=7 ans: 475020 On Oct 10, 9:51 am, vicky mehta...@gmail.com wrote: u have to color n similar balls with k diff. colors , such that every color must be