[algogeeks] Re: check Similar array

2012-01-05 Thread WgpShashank
1st of all Happy New Year to All :) Must be both have same length also test some other test cases, :) Let me share things striking in mind , if you calculate the sum of power of 1st array by taking any number as base , remaining all the numbers as exponent so if take 3 as base calculate

[algogeeks] Re: Find the path in two nodes of a binary search tree

2012-01-05 Thread WgpShashank
@top coder , if its given that that you have to nodes as input , 1st find the two nodes , store their address then do any traversal to get the path between them , inorder will good . i ams assuming you wants to print the path between two such nodes. hope it suffices :) let me know if approach

[algogeeks] Re: Best way to rank sentences based on similarity from a set of Documents

2012-01-05 Thread WgpShashank
HI Anantha , I had similer discussion long time back , although its not full final but similer ,i hope it will gives you some idea . http://www.linkedin.com/groups/Detecting-Duplicate-Documents-1210167%2ES%2E55684470?qid=eb015784-36a3-498d-8441-558ace3b4038trk=group_items_see_more-0-b-ttl

[algogeeks] Re: Find even length palindrome.

2012-01-05 Thread WgpShashank
@atul , its should be the either 1st even length palindrome or largest even length palindrome in question , so here we go while making problem more generic ,* given a string find the largest palindrome in that string * So As I Coded it Some Times Back , Have a Look

Re: [algogeeks] Re: Find even length palindrome.

2012-01-05 Thread WgpShashank
you can use Suffix Tree for more better efficiency Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra *http://shashank7s.blogspot.com* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the

[algogeeks] Re: finding all combination

2012-01-05 Thread WgpShashank
@atul ,FYI, another naive approach will to generate the all subset of given set , thats the power set , has complexity O(n*2^n) , obviously not better then upper one , but still you can try to figure out the sum problem , you will get some relation to DP. Thanks Shashank Mani Computer

Re: [algogeeks] Re: Best way to rank sentences based on similarity from a set of Documents

2012-01-05 Thread Goutam Nayak
You are given 'n' strings w1, w2, .., wn. Let Si denote the set of strings formed by considering all unique substrings of the string wi. A substring is defined as a contiguous sequence of one or more characters in the string. More information on substrings can be found

Re: [algogeeks] Re: Find the path in two nodes of a binary search tree

2012-01-05 Thread atul anand
@shashank : i am not sure if i am getting it right but are you saying save address of 2 nodes. now do inorder traversal considering node1 as the starting point , during traversal if we find node2 then return. if that so , then i dont think so it will work for all the cases. please correct me if

Re: [algogeeks] Re: Find the path in two nodes of a binary search tree

2012-01-05 Thread WgpShashank
@atul ,, why it won;t work , any clarification ? Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra *http://shashank7s.blogspot.com* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web

Re: [algogeeks] Re: Find the path in two nodes of a binary search tree

2012-01-05 Thread atul anand
1) suppose node1 is at level = 4 of the tree and node2 is at level = 3 of the tree if you do inorder traversal from node1 i.e calling function inorder(node1); now it will search form level 4 to the max depth of the tree it will never reach node2 because it is at level = 3. 2) suppose root of the

Re: [algogeeks] Re: check Similar array

2012-01-05 Thread atul anand
@Shashank : as i have mentioned in the question , no sorting allowed. if question would have allowed sorting then why not sort both array and compare it would be much simpler and no need of doing costlier operation like finding power. complexity = O(nogn) + O(mlogm) + O(n) -- You received this

[algogeeks] find point lies in side circle

2012-01-05 Thread dabbcomputers
you are given with N points on graph. and a point A on graph and range R you have to find the points that lies within the radius of R from point A. with complexity less than O(N). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Re: check Similar array

2012-01-05 Thread saurabh singh
Some very nice approaches have been presented but I still feels for practical situations its better to sort and compare..All other algorithms presented above restricts the max value for an element in the array.In case the maximum value is small,we can simply count sort,and the algorithm will

[algogeeks] Re: find point lies in side circle

2012-01-05 Thread Lucifer
Assuming that the N points on the graph are represented in the form of (x,y) i.e. cartesian coordinates.. Then say, A = ( a1, a2); The equation of the circle centered at A would be (x - a1)^2 + (y-a2)^2 = R^2... Now, to find the points that lie within the range R, u need to check the following

[algogeeks] Re: find point lies in side circle

2012-01-05 Thread Lucifer
@ all Ignore my previous post On Jan 5, 5:58 pm, Lucifer sourabhd2...@gmail.com wrote: Assuming that the N points on the graph are represented in the form of (x,y) i.e. cartesian coordinates.. Then say, A = ( a1, a2); The equation of the circle centered at A would be (x - a1)^2 +

Re: [algogeeks] Re: check Similar array

2012-01-05 Thread WgpShashank
@atul..no need to sorting , complexity will be O(nlogn) only , sorting makes searching easy so said to sort , u can linearly search that elemnt in 2nd array it will take O(m) in above case . finally complexity will be O(nlogn) only Let me know if anything wrong or missed something ? Thanks

[algogeeks] A graph problem

2012-01-05 Thread saurabh singh
This problem is taken from www.codeforces.com.What can be the possible approaches?? A smile house is created to raise the mood. It has *n* rooms. Some of the rooms are connected by doors. For each two rooms (number *i*and *j*), which are connected by a door, Petya knows their value *c**ij* —

[algogeeks] Re: A graph problem

2012-01-05 Thread WgpShashank
@Saurabh DFS Should Work Here, Start from any room i , visit next room connected to it .. then to this room so on , once you back track you will back to the starting node ,this way you can find out .min.umber of room he need to visit will be 2 times of traversal isn't it ? posting the

Re: [algogeeks] C output????

2012-01-05 Thread teja bala
depends on compiler i think..but most probably it compares the addresses. On Wed, Jan 4, 2012 at 12:20 PM, saurabh singh saurab...@gmail.com wrote: @all.Your explanations work because probably all of you are using a compiler that's behaving in the same way.Don't conclude from what

Re: [algogeeks] Re: A graph problem

2012-01-05 Thread karthikeyan muthu
find the size of smallest cycle in the given graph ... tarjan should do the trick.. dfs basically ... :) On Thu, Jan 5, 2012 at 7:02 PM, WgpShashank shashank7andr...@gmail.comwrote: @Saurabh DFS Should Work Here, Start from any room i , visit next room connected to it .. then to this room

Re: [algogeeks] Re: A graph problem

2012-01-05 Thread saurabh singh
Yes I also initially thought soBut how do we take into consideration the edge weights??The cycle can include such edges whose total cost may come negative. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Thu, Jan 5, 2012 at 10:01 PM, karthikeyan

[algogeeks] Re: find point lies in side circle

2012-01-05 Thread Don
Cut out the circle from the graph. The points on the cut-out circle are the answer. Don On Jan 5, 6:17 am, dabbcomputers dabbcomput...@gmail.com wrote: you are given with N points on graph. and a point A on graph and range R you have to find the points that lies within the radius of R from

Re: [algogeeks] Re: Longest sequence of numbers with atmost diff K

2012-01-05 Thread atul anand
@Lucifier : i was considering algo as mentioned by you and was considering heap with indexes as mentioned in your first post i.e :- /* Also, though the MinH and MaxH is designed based on the element values i.e A[i], but we will store only the index of the element i.e. 'i'. // The above app will

[algogeeks] Re: A graph problem

2012-01-05 Thread Don
The problem with the proposed depth first search is that it can try many very long paths, requiring exponential time, before it ever finds the correct cycle, even if the cycle is very short. A breadth-first search will avoid this, and using dynamic programming principles can accomplish the

[algogeeks] Re: Longest sequence of numbers with atmost diff K

2012-01-05 Thread Lucifer
@atul.. you are not getting it wrong.. Its absolutely correct On Jan 5, 11:28 pm, atul anand atul.87fri...@gmail.com wrote: @Lucifier : i was considering algo as mentioned by you and was considering heap with indexes as mentioned in your first post i.e :- /* Also, though the MinH

Re: [algogeeks] find point lies in side circle

2012-01-05 Thread UTKARSH SRIVASTAV
we can do bfs. from the point A do bfs until distance = R On Fri, Jan 6, 2012 at 12:47 AM, shady sinv...@gmail.com wrote: problem link ? On Thu, Jan 5, 2012 at 5:47 PM, dabbcomputers dabbcomput...@gmail.comwrote: you are given with N points on graph. and a point A on graph and range R

Re: [algogeeks] find point lies in side circle

2012-01-05 Thread amrit harry
@shady this problem is not from the online contest. i need this in my project @utkarsh please elloborate your idea in more detail On Fri, Jan 6, 2012 at 9:40 AM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: we can do bfs. from the point A do bfs until distance = R On Fri, Jan

Re: [algogeeks] Re: find point lies in side circle

2012-01-05 Thread amrit harry
i also think so data must be represent in some special form i heard about K-D trees but not yet studied about it On Fri, Jan 6, 2012 at 12:26 PM, Lucifer sourabhd2...@gmail.com wrote: @all.. To decide which points are within the range R, we need to look a each point..Hence the

Re: [algogeeks] Re: find point lies in side circle

2012-01-05 Thread shady
the reason i asked you about problem link is because the solution to your problem depends on the way you want to use it... 1. if each time there are new N points and radius R, and only one query for it...then it just can't be O(n) 2. if N points are fixed and there are like 1+ queries then

Re: [algogeeks] Re: find point lies in side circle

2012-01-05 Thread amrit harry
@shady the N is same we just have to query the data again and again On Fri, Jan 6, 2012 at 12:47 PM, shady sinv...@gmail.com wrote: the reason i asked you about problem link is because the solution to your problem depends on the way you want to use it... 1. if each time there are new N