[algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread rahul sharma
i have 2 pointers fast and slow.now if tehy meet there is a loop... now keep one ptr at meeting point and take other one to the begining of listmove both at speed of one..they will meet at start of loophow this happens???why they meet at start..plz tell logic behind this???thnx in

Re: [algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread sanjiv yadav
No They will not meet at the start in a case containing 5 nods and having loop at the third node. once check this On Fri, Mar 9, 2012 at 3:48 PM, rahul sharma rahul23111...@gmail.comwrote: i have 2 pointers fast and slow.now if tehy meet there is a loop... now keep one ptr at meeting

Re: [algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread Terence
@ rahul sharma: the linked list is a combination of a list a-b-...-p-q and a cycle q-r-...-z-q. (z != p). noting that the start of cycle q is the only node with 2 predecessor: p and z. if 2 pointers meet at some node x, different from q, in last step they must have met at x', the predecessor

Re: [algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread rahul sharma
@terencei cant get..can u eleboratethnx for the sol..but plz elaborate... On Fri, Mar 9, 2012 at 5:59 PM, Terence technic@gmail.com wrote: @ rahul sharma: the linked list is a combination of a list a-b-...-p-q and a cycle q-r-...-z-q. (z != p). noting that the start of cycle q

Re: [algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread sanjiv yadav
suppose linked list is a-b-c-d-e and suppose loop starts from 'c' according to u let one pointer be at 'c' say *q and another be at 'a' say *p. Now if we move both at the speed of one then After first pass p will be at b q will be at d After second pass p will be at c q will be at e

[algogeeks] A strange doubt with cpp class. Why compile error ?

2012-03-09 Thread ~*~VICKY~*~
#includeiostream using namespace std; class Abc { public : int i; Abc(){ i = 0;} }; int main() { Abc a = new Abc(); couta.i; } -- Cheers, Vicky -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] A strange doubt with cpp class. Why compile error ?

2012-03-09 Thread sanjiv yadav
write.. Abc a=Abc() it will execute... On Fri, Mar 9, 2012 at 8:15 PM, ~*~VICKY~*~ venkat.jun...@gmail.com wrote: #includeiostream using namespace std; class Abc { public : int i; Abc(){ i = 0;} }; int main() { Abc a = new Abc(); couta.i; } -- Cheers,

Re: [algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread rahul sharma
@sanjiv...how can u take q at c.they will meet at some position ... suppose u have 1-2-3-4-5-6-7-4 now initialy slow and fast both at 1 start incrementing slow by 1 and fast by 2 slow @2 ...fast @3 slow @3fast @5 s...@4...fast@7 slow @5...fast@5 both are equalmeans dere is

Re: [algogeeks] A strange doubt with cpp class. Why compile error ?

2012-03-09 Thread rahul sharma
on left side of new there should be pointer that should collect the address of the memory allocated.. write. ABC *a=new ABC(); correct if wrng... On Fri, Mar 9, 2012 at 8:19 PM, sanjiv yadav sanjiv2009...@gmail.comwrote: write.. Abc a=Abc() it will execute... On Fri, Mar 9, 2012 at

Re: [algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread sanjiv yadav
I think u r making mistake i.e. after 7,5 will com not 4 because loop starts from 5.check it again On 3/9/12, rahul sharma rahul23111...@gmail.com wrote: @sanjiv...how can u take q at c.they will meet at some position ... suppose u have 1-2-3-4-5-6-7-4 now initialy slow and fast

Re: [algogeeks] A strange doubt with cpp class. Why compile error ?

2012-03-09 Thread atul anand
may u r confused with java Abc a ; // this itself is creating an object of type ABC in C++ , no need to use new keyword to allocate m/m. where as in C++ new keyword allocate m/m and return an address , so to make it work do. Abc *a=new ABC(); On Fri, Mar 9, 2012 at 8:28 PM, rahul sharma

[algogeeks] RBS internship paper

2012-03-09 Thread deepikaanand
First Rounf : Aptitude paper :- three section(Quant,aptitude,verabal) 20 qs each part negative marking after 25 % of wrong attempts quant was quite difficult :- 1.questions from area of triangle(two find a side if longest side and other side along with area is given) 2.(loga + log b + log

Re: [algogeeks] Doubt in removing loop from linked list

2012-03-09 Thread rahul sharma
itz ryt...loop starts from 4 n not from 5... On Fri, Mar 9, 2012 at 8:58 PM, sanjiv yadav sanjiv2009...@gmail.comwrote: I think u r making mistake i.e. after 7,5 will com not 4 because loop starts from 5.check it again On 3/9/12, rahul sharma rahul23111...@gmail.com wrote:

[algogeeks] Re: Doubt in removing loop from linked list

2012-03-09 Thread Dave
@Rahul: You have to figure out where the fast and slow pointers meet, which will depend on the distance m from the head to the cycle and the period p of the cycle. It is awkward to explain in words, so draw a picture and label it according to this discussion. Suppose the two pointers meet k

Re: [algogeeks] Re: Doubt in removing loop from linked list

2012-03-09 Thread rahul sharma
@dave.. plz tell use of variable...m and p?? p i thnik no. of nodes in cycle..??? plz tell what is p and m On Fri, Mar 9, 2012 at 10:16 PM, Dave dave_and_da...@juno.com wrote: @Rahul: You have to figure out where the fast and slow pointers meet, which will depend on the distance m from

[algogeeks] find longest common contiguous intersection from 2 lists

2012-03-09 Thread payal gupta
find the efficient implementation to find longest common contiguous intersection from 2 lists provided to the function. Example: list1: abcrfghwetf list2: abrfghwwetxyab Longest common intersection here is: rfghw need the suffix array implementation in c... thnx..in advance!! -- You

Re: [algogeeks] Re: Doubt in removing loop from linked list

2012-03-09 Thread sanjiv yadav
actually how u r moving from 7 to 4? can tell me in the detail... On Sat, Mar 10, 2012 at 4:37 AM, Dave dave_and_da...@juno.com wrote: @Rahul: The definitions of m and p are in the first sentence of the posting. Dave On Friday, March 9, 2012 12:46:43 PM UTC-6, rahul sharma

[algogeeks] Re: find longest common contiguous intersection from 2 lists

2012-03-09 Thread Sonia Keys
This? http://en.wikipedia.org/wiki/Longest_common_substring_problem On Friday, March 9, 2012 2:30:57 PM UTC-5, payal gupta wrote: find the efficient implementation to find longest common contiguous intersection from 2 lists provided to the function. Example: list1: abcrfghwetf list2:

Re: [algogeeks] Suggest some Data Structure appropriate to the problem

2012-03-09 Thread Sonia Keys
On Monday, March 5, 2012 5:33:46 PM UTC-5, Sehaj wrote: ... I was asked this question during an interview, so I think there must/might be some possible solution. Ha. I wouldn't draw that conclusion. They are fishing for what you know. Theoretical limits are good to know. So are

Re: [algogeeks] RBS internship paper

2012-03-09 Thread saurabh arora
which college -- 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+unsubscr...@googlegroups.com. For more options, visit this