Re: [algogeeks] Re: Amazon Question make confused !!!!!!!

2010-09-15 Thread Terence



You could also get a unique solution if the car has speed of 72 63 56
in downhill, plain and uphill respectively.

I think the speed Vd, Vp, Vu was chosen so that 2Vp = Vd + Vu.
But for unique solution, it ought to be 2/Vp = 1/Vd + 1/Vu.

Under this condition, we can get the unique S=x+y+z:
From
   x/Vd + y/Vp + z/Vu = T1
   x/Vu + y/Vp + z/Vd = T2
We get (1/Vu+1/Vd)(x+z)+2/Vp*y = T1+T2
Apply 2/Vp = 1/Vd + 1/Vu, then 2/Vp(x+y+z)=T1+T2
S=x+y+z = Vp(T1+T2)/2


On 2010-9-15 9:31, Gene wrote:

This isn't right.  Dropping both y terms is the same as setting y to
zero.  The answer you get is correct, but there are many others as has
been said.

You could get a unique solution if the route were constrained to be
monotonic (level and up or else level and down).

On Sep 14, 4:28 pm, Minotaurausanike...@gmail.com  wrote:

Actually the solution is unique. The middle part with the Ys is the
same and therefore can be omitted out. Now you are left with
2 equations and 2 unknowns.

I used time in minutes and I have x = 1.28, z = 0.30476 units (y can
be found out).

I guess the trick was 1. to write the equations that Yan did
and 2. to recognize that the plain part is the same and hence can be
cancelled.

On Sep 14, 3:31 am, Yan Wangwangyanadam1...@gmail.com  wrote:




actually, there are many solutions, just pick up one from them...
On Tue, Sep 14, 2010 at 3:23 AM, Abhilasha jain
mail2abhila...@gmail.com  wrote:

how can u solve 3 variables using 2 equations?
On Tue, Sep 14, 2010 at 3:44 PM, Yan Wangwangyanadam1...@gmail.com  wrote:

x/72 + y/64 + z/56 = 4

x/56 + y/64 + z/72 = 4+2/3
find a solution to this ...
On Tue, Sep 14, 2010 at 2:31 AM, bittushashank7andr...@gmail.com  wrote:

Amazon Interview Question for Software Engineer / Developers
A car has speed of 72 64 56 in downhill, plain and uphill
respectively . A guy travels in the car from Pt. A to pt. B in 4 Hrs
and pt. B to pt. A in 4 Hrs and 40 min. what is the distance between A
and B?
Regards
Shashank
--
You received this message because you are subscribed to the Google
Groups Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.

--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.

--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -

- Show quoted text -


--
You received this message because you are subscribed to the Google Groups Algorithm 
Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Excellent Compilation of Interview Questions

2010-09-15 Thread Amit Agarwal
http://tinyurl.com/2wjnofr

-Regards
Amit Agarwal



On Wed, Sep 15, 2010 at 10:41 AM, saurabh singh saurabh.n...@gmail.comwrote:

 haha...no one knows now what was the true source of that solutionlot of
 stuff on same kind of problem is lying on web on tons of web-sitesthe
 only change in sol i can observe mostly is change in variable names :)


 On Tue, Sep 14, 2010 at 10:55 PM, TurksHead Education 
 turksheadeducat...@gmail.com wrote:

 Shame on you.. you have copied the articles as it is from other sites. For
 example, the article 
 http://www.cracktheinterview.org/2010/08/converting-a-tree-to-a-doubly-linked-list/;
 is an exact copy-paste from rawkam.com. So much so that the images still
 point to images of rawkam.com


 On Sat, Sep 11, 2010 at 1:26 AM, Shashank Krishna sasan...@gmail.comwrote:

 Excellent Compilation of Interview Questions
 Visit
 http://www.cracktheinterview.org/

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Thanks  Regards,
 Saurabh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Yahoo!!!! Puzzle

2010-09-15 Thread jaladhi dave
This looked like a variant of the socks problem :)

On Tue, Sep 14, 2010 at 5:20 PM, Sathaiah Dontula don.sat...@gmail.comwrote:

 How_to_Ace_the_Brainteaser_Interview.pdf

 find this book, this has good number of puzzles.

 Thanks,
 Sathaiah Dontula


 On Tue, Sep 14, 2010 at 3:01 PM, vishal raja vishal.ge...@gmail.comwrote:

 take out that one A pill that's there in the jar. take the half of all the
 four pills, that's how u'll make sure that u've had 1 of 'A' and 1 of 'B'
 pill.



 On Tue, Sep 14, 2010 at 2:52 PM, bittu shashank7andr...@gmail.comwrote:

 You are on a strict medical regimen that requires you to take two
 types of pills each day. You must take exactly one A pill and exactly
 one B pill at the same time. The pills are very expensive, and you
 don't want to waste any. So you open the bottle of A pills, and tap
 one out into your hand. Then you open the bottle of B pills and do the
 same thing -- but you make a mistake, and two B pills come out into
 your hand with the A pill. But the pills are all exactly identical.
 There is no way to tell A pills apart from B pills. How can you
 satisfy your regimen and take exactly one of each pill at the same
 time, without wasting any pills?


 Write  Algorithm to Solve dis Problem in  constant time..isn't it..???





 Regard's
 Shashank Mani Narayan  Don't Be Evil U Can Earn While U learn
 Computer Science  Engineering
 Birla Institute of  Technology,Mesra
 Cell No. +91-9166674831

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Question make confused !!!!!!!

2010-09-15 Thread rahul patil
the solution seems to be simple.
Just try to imagine what is happening

You have a road with downhill and uphill.
So if u travel 5 km uphill and then 5 km on plain and then 5 km on downhill
then time taken
by you will be equal to 15 km on the plain road(that is solely due avg of
speed of downhill and uphill is = speed on plain road)

so the from A to B we reach 40 min earlier due to there more downhill road.
while from A to B it is uphill.

So let us take x km as the road distance which is not plain.

t1 = time to travel x on downhill = x/72
t2 = time to travel x on uphill = x/56

but as given 40min =  2/3 hr = x/56 - x/72

so, x= 168.

so it will take 3 hrs to climb while travelling from B to A and plain road
distance = 5/3 * 64 = 106.67 km
dist = 168 + 106.67
On Wed, Sep 15, 2010 at 8:21 AM, Terence technic@gmail.com wrote:



 You could also get a unique solution if the car has speed of 72 63 56

 in downhill, plain and uphill respectively.

 I think the speed Vd, Vp, Vu was chosen so that 2Vp = Vd + Vu.
 But for unique solution, it ought to be 2/Vp = 1/Vd + 1/Vu.

 Under this condition, we can get the unique S=x+y+z:
 From
   x/Vd + y/Vp + z/Vu = T1
   x/Vu + y/Vp + z/Vd = T2
 We get (1/Vu+1/Vd)(x+z)+2/Vp*y = T1+T2
 Apply 2/Vp = 1/Vd + 1/Vu, then 2/Vp(x+y+z)=T1+T2
 S=x+y+z = Vp(T1+T2)/2



 On 2010-9-15 9:31, Gene wrote:

 This isn't right.  Dropping both y terms is the same as setting y to
 zero.  The answer you get is correct, but there are many others as has
 been said.

 You could get a unique solution if the route were constrained to be
 monotonic (level and up or else level and down).

 On Sep 14, 4:28 pm, Minotaurausanike...@gmail.com  wrote:

 Actually the solution is unique. The middle part with the Ys is the
 same and therefore can be omitted out. Now you are left with
 2 equations and 2 unknowns.

 I used time in minutes and I have x = 1.28, z = 0.30476 units (y can
 be found out).

 I guess the trick was 1. to write the equations that Yan did
 and 2. to recognize that the plain part is the same and hence can be
 cancelled.

 On Sep 14, 3:31 am, Yan Wangwangyanadam1...@gmail.com  wrote:



  actually, there are many solutions, just pick up one from them...
 On Tue, Sep 14, 2010 at 3:23 AM, Abhilasha jain
 mail2abhila...@gmail.com  wrote:

 how can u solve 3 variables using 2 equations?
 On Tue, Sep 14, 2010 at 3:44 PM, Yan Wangwangyanadam1...@gmail.com
  wrote:

 x/72 + y/64 + z/56 = 4
 
 x/56 + y/64 + z/72 = 4+2/3
 find a solution to this ...
 On Tue, Sep 14, 2010 at 2:31 AM, bittushashank7andr...@gmail.com
  wrote:

 Amazon Interview Question for Software Engineer / Developers
 A car has speed of 72 64 56 in downhill, plain and uphill
 respectively . A guy travels in the car from Pt. A to pt. B in 4 Hrs
 and pt. B to pt. A in 4 Hrs and 40 min. what is the distance between
 A
 and B?
 Regards
 Shashank
 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google
 Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google
 Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -

 - Show quoted text -


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards,
Rahul Patil

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Question

2010-09-15 Thread sharad kumar
you dont have the structure of the node

typedef  struct member node
{
int data;
struct member * next;
}ll;

On Tue, Sep 14, 2010 at 5:57 PM, soundar soundha...@gmail.com wrote:

 From first linked list set flag value in each traversal of
 node..then start from second linked list suppose if flag value is
 already set that is the intersection point

 correct me if i am wrong

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
yezhu malai vaasa venkataramana Govinda Govinda

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Question make confused !!!!!!!

2010-09-15 Thread Terence


So if u travel 5 km uphill and then 5 km on plain and then 5 km on 
downhill then time taken

by you will be equal to 15 km on the plain road

This is not the truth.
5/72 + 5/64 + 5/56  - 15/64  = 5/72+5/56-10/64 = 10/63-10/64  0
(that is solely due avg of speed of downhill and uphill is = speed on 
plain road)

This only leads to:
if u travel 5 hrs uphill and then 5 hrs on plain and then 5 hrs on 
downhill then distance traveled

by you will be equal to travel 15 hrs on the plain road.


On 2010-9-15 15:07, rahul patil wrote:

the solution seems to be simple.
Just try to imagine what is happening

You have a road with downhill and uphill.
So if u travel 5 km uphill and then 5 km on plain and then 5 km on 
downhill then time taken
by you will be equal to 15 km on the plain road(that is solely due avg 
of speed of downhill and uphill is = speed on plain road)


so the from A to B we reach 40 min earlier due to there more downhill 
road.

while from A to B it is uphill.

So let us take x km as the road distance which is not plain.

t1 = time to travel x on downhill = x/72
t2 = time to travel x on uphill = x/56

but as given 40min =  2/3 hr = x/56 - x/72

so, x= 168.

so it will take 3 hrs to climb while travelling from B to A and plain 
road distance = 5/3 * 64 = 106.67 km

dist = 168 + 106.67
On Wed, Sep 15, 2010 at 8:21 AM, Terence technic@gmail.com 
mailto:technic@gmail.com wrote:




You could also get a unique solution if the car has speed of 72 63 56

in downhill, plain and uphill respectively.

I think the speed Vd, Vp, Vu was chosen so that 2Vp = Vd + Vu.
But for unique solution, it ought to be 2/Vp = 1/Vd + 1/Vu.

Under this condition, we can get the unique S=x+y+z:
From
  x/Vd + y/Vp + z/Vu = T1
  x/Vu + y/Vp + z/Vd = T2
We get (1/Vu+1/Vd)(x+z)+2/Vp*y = T1+T2
Apply 2/Vp = 1/Vd + 1/Vu, then 2/Vp(x+y+z)=T1+T2
S=x+y+z = Vp(T1+T2)/2



On 2010-9-15 9:31, Gene wrote:

This isn't right.  Dropping both y terms is the same as
setting y to
zero.  The answer you get is correct, but there are many
others as has
been said.

You could get a unique solution if the route were constrained
to be
monotonic (level and up or else level and down).

On Sep 14, 4:28 pm, Minotaurausanike...@gmail.com
mailto:anike...@gmail.com  wrote:

Actually the solution is unique. The middle part with the
Ys is the
same and therefore can be omitted out. Now you are left with
2 equations and 2 unknowns.

I used time in minutes and I have x = 1.28, z = 0.30476
units (y can
be found out).

I guess the trick was 1. to write the equations that Yan did
and 2. to recognize that the plain part is the same and
hence can be
cancelled.

On Sep 14, 3:31 am, Yan Wangwangyanadam1...@gmail.com
mailto:wangyanadam1...@gmail.com  wrote:



actually, there are many solutions, just pick up one
from them...
On Tue, Sep 14, 2010 at 3:23 AM, Abhilasha jain
mail2abhila...@gmail.com
mailto:mail2abhila...@gmail.com  wrote:

how can u solve 3 variables using 2 equations?
On Tue, Sep 14, 2010 at 3:44 PM, Yan
Wangwangyanadam1...@gmail.com
mailto:wangyanadam1...@gmail.com  wrote:

x/72 + y/64 + z/56 = 4

x/56 + y/64 + z/72 = 4+2/3
find a solution to this ...
On Tue, Sep 14, 2010 at 2:31 AM,
bittushashank7andr...@gmail.com
mailto:shashank7andr...@gmail.com  wrote:

Amazon Interview Question for Software
Engineer / Developers
A car has speed of 72 64 56 in downhill,
plain and uphill
respectively . A guy travels in the car
from Pt. A to pt. B in 4 Hrs
and pt. B to pt. A in 4 Hrs and 40 min.
what is the distance between A
and B?
Regards
Shashank
--
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
mailto:algogeeks@googlegroups.com.
To unsubscribe from this group, send email to

[algogeeks] Yahoo Question

2010-09-15 Thread bittu
You are given k sorted lists with total n inputs in all the lists
devise a algorithm to merge them into one single sorted list in O(n
logk)



Regard's
Shashank Mani Narayan  Don't Be Evil U Can Earn While U learn
Computer Science  Engineering
Birla Institute of  Technology,Mesra
Cell No. +91-9166674831

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Yahoo Question

2010-09-15 Thread Rahul Singal
1. Take single element from each list . Put it in array maintaining min heap
property ,
2. Copy the lowest element ( O(1) ) from the heap to the single sorted list
thand delete the element from heap.
3. Insert a new element into the heap ( O(logk) ) from list belonging to the
deleted element .
4. repeat 2 and 3 till all list are empty.

Regards
Rahul Singal
3rd yr , Computer Science Department
Birla Institute of technology and Science , Pilani

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Amazon Interview

2010-09-15 Thread bittu
A file is given with many 0s stored in continuous way , store it in
another file such that when you store try saving the space by using
minimum amount of space. When you want to create the original file ,
you should be able to do so with the new file created


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Amazon intern Question

2010-09-15 Thread Arun
bump!!

On Sep 5, 8:42 pm, Arun yourarunb...@gmail.com wrote:
 Hi friends,
 Sorry that I am so late to reply.

 Thanks much responses have come regarding finding the similarity
 between words.

 Now what about the searching algorithm from the 'millions of words'. I
 think they expected an answer like hashing or more multi-level
 hashing. But  I cant figureout an idea regarding the hash function and
 also about multi-level hashing,

 Regards

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Amazon Interview

2010-09-15 Thread BHARATH NITHIN N
-- One can store the binary equivalent of the number of zeros in each
line... and carry on from there

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Amazon Question

2010-09-15 Thread bittu
Propose a data structure that would store numbers, without any
knowledge about them, and allow to perform the operations: insert, get
median, as efficiently as possible same as before, only this time the
numbers are from a group V, which is |V|n

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Question

2010-09-15 Thread Terence
 The following algorithm traversals both lists twice to find the 
intersection point, without modification to the original nodes.


The only assumptions:
1) Head pointer of two list: La, Lb
2) .next point to the next node.
3) .next of the tail node is NULL

intersect(La,Lb)
{
  // Find the length difference of two lists
  for (pA = La, pB = Lb; pA != NULL  pB != NULL; pA = pA-next, pB = 
pB-next);


  // Discard the beginning of the longer list, to get equal length as 
the shorter one.

  if(pA != NULL) {
for(pC = pA, pA = La; pC != NULL; pA = pA-next, pC = pC-next);
pB = Lb;
  } else if(pB != NULL) {
for(pC = pB, pB = Lb; pC != NULL; pB = pB-next, pC = pC-next);
pA = La;
  }

  // Traversal both list, until we get a common node, return this node.
  // If no such intersection, NULL is returned. (pA,pB will get NULL at 
the same time)

  for( ; pA != pB; pA = pA-next, pB = pB-next);
  return pA;
}


On 2010-9-15 15:50, sharad kumar wrote:

you dont have the structure of the node
typedef  struct member node
{
int data;
struct member * next;
}ll;

On Tue, Sep 14, 2010 at 5:57 PM, soundar soundha...@gmail.com 
mailto:soundha...@gmail.com wrote:


From first linked list set flag value in each traversal of
node..then start from second linked list suppose if flag value is
already set that is the intersection point

correct me if i am wrong

--
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
mailto:algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com
mailto:algogeeks%2bunsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.




--
yezhu malai vaasa venkataramana Govinda Govinda
--
You received this message because you are subscribed to the Google 
Groups Algorithm Geeks group.

To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.


--
You received this message because you are subscribed to the Google Groups Algorithm 
Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Yahoo Question

2010-09-15 Thread Chonku
Use k way merging

On Wed, Sep 15, 2010 at 3:30 PM, bittu shashank7andr...@gmail.com wrote:

 You are given k sorted lists with total n inputs in all the lists
 devise a algorithm to merge them into one single sorted list in O(n
 logk)



 Regard's
 Shashank Mani Narayan  Don't Be Evil U Can Earn While U learn
 Computer Science  Engineering
 Birla Institute of  Technology,Mesra
 Cell No. +91-9166674831

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Yahoo Question

2010-09-15 Thread ankur aggarwal
use heap.. k node min / max heap.


On Wed, Sep 15, 2010 at 3:30 PM, bittu shashank7andr...@gmail.com wrote:

 You are given k sorted lists with total n inputs in all the lists
 devise a algorithm to merge them into one single sorted list in O(n
 logk)



 Regard's
 Shashank Mani Narayan  Don't Be Evil U Can Earn While U learn
 Computer Science  Engineering
 Birla Institute of  Technology,Mesra
 Cell No. +91-9166674831

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 

With Regards
Ankur Aggarwal
+91-7838289304

Software Engineer
Slideshare
Delhi
INDIA.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Excellent Compilation of Interview Questions

2010-09-15 Thread Shashank Krishna
@TurksHead
gimme a break dude!..as if all the content u host is legit n copyrighted
Regards,
Sasank Krishna
http://krishna-shashank.co.nr/
 http://krishna-shashank.co.nr/http://www.cracktheinterview.org/







On Tue, Sep 14, 2010 at 10:55 PM, TurksHead Education 
turksheadeducat...@gmail.com wrote:

 Shame on you.. you have copied the articles as it is from other sites. For
 example, the article 
 http://www.cracktheinterview.org/2010/08/converting-a-tree-to-a-doubly-linked-list/;
 is an exact copy-paste from rawkam.com. So much so that the images still
 point to images of rawkam.com

 On Sat, Sep 11, 2010 at 1:26 AM, Shashank Krishna sasan...@gmail.comwrote:

 Excellent Compilation of Interview Questions
 Visit
 http://www.cracktheinterview.org/

 --

 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Amazon Question make confused !!!!!!!

2010-09-15 Thread Gene
No.  Two linear equations in three unknowns will always yield many
solutions (or zero solutions).  These are essentially plane
equations.  Two planes intersect in a line (unless they are
parallel).  You might get a de facto unique solution for some values
of Vu, Vd, Vu, T1, T2 from the constraints x,y,z = 0.  It would have
to lie on an axis.

For example, you can aways pick z and find x and y.  Using your
notation,

 x/Vd + y/Vp + z/Vu = T1
 x/Vu + y/Vp + z/Vd = T2

Subtract to get:

x(1/Vd - 1/Vu) + z(1/Vu - 1/Vd) = T1 - T2

then

x = [ (T1 - T2) - z(1/Vu - 1/Vd) ] / (1/Vd - 1/Vu)

So now you can pick any z and get x.  Once you have both of these,
plug them in here:

y = Vp (T1 - x/Vd - z/Vu)

As long as x,y,z = 0, you are in business.

On Sep 14, 10:51 pm, Terence technic@gmail.com wrote:
 You could also get a unique solution if the car has speed of 72 63 56
 in downhill, plain and uphill respectively.

 I think the speed Vd, Vp, Vu was chosen so that 2Vp = Vd + Vu.
 But for unique solution, it ought to be 2/Vp = 1/Vd + 1/Vu.

 Under this condition, we can get the unique S=x+y+z:
 From
     x/Vd + y/Vp + z/Vu = T1
     x/Vu + y/Vp + z/Vd = T2
 We get (1/Vu+1/Vd)(x+z)+2/Vp*y = T1+T2
 Apply 2/Vp = 1/Vd + 1/Vu, then 2/Vp(x+y+z)=T1+T2
 S=x+y+z = Vp(T1+T2)/2

 On 2010-9-15 9:31, Gene wrote:



  This isn't right.  Dropping both y terms is the same as setting y to
  zero.  The answer you get is correct, but there are many others as has
  been said.

  You could get a unique solution if the route were constrained to be
  monotonic (level and up or else level and down).

  On Sep 14, 4:28 pm, Minotaurausanike...@gmail.com  wrote:
  Actually the solution is unique. The middle part with the Ys is the
  same and therefore can be omitted out. Now you are left with
  2 equations and 2 unknowns.

  I used time in minutes and I have x = 1.28, z = 0.30476 units (y can
  be found out).

  I guess the trick was 1. to write the equations that Yan did
  and 2. to recognize that the plain part is the same and hence can be
  cancelled.

  On Sep 14, 3:31 am, Yan Wangwangyanadam1...@gmail.com  wrote:

  actually, there are many solutions, just pick up one from them...
  On Tue, Sep 14, 2010 at 3:23 AM, Abhilasha jain
  mail2abhila...@gmail.com  wrote:
  how can u solve 3 variables using 2 equations?
  On Tue, Sep 14, 2010 at 3:44 PM, Yan Wangwangyanadam1...@gmail.com  
  wrote:
  x/72 + y/64 + z/56 = 4
  
  x/56 + y/64 + z/72 = 4+2/3
  find a solution to this ...
  On Tue, Sep 14, 2010 at 2:31 AM, bittushashank7andr...@gmail.com  
  wrote:
  Amazon Interview Question for Software Engineer / Developers
  A car has speed of 72 64 56 in downhill, plain and uphill
  respectively . A guy travels in the car from Pt. A to pt. B in 4 Hrs
  and pt. B to pt. A in 4 Hrs and 40 min. what is the distance between A
  and B?
  Regards
  Shashank
  --
  You received this message because you are subscribed to the Google
  Groups Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
  --
  You received this message because you are subscribed to the Google 
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text -
  - Show quoted text -- Hide quoted text -

 - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] num to words

2010-09-15 Thread Raj Jagvanshi
display a num in words
ex: 38 = thirty eight;
  4567 = four thousand five hundred sixty seven.

give me algo



Thanks
Raj

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Recursion!!!!!!!!!!! Always Stuck

2010-09-15 Thread TurksHead Education
Recursion:
 http://www.rawkam.com/?p=283
http://www.rawkam.com/?p=283Tower Of Hanoi:
 http://www.rawkam.com/?p=917
http://www.rawkam.com/?p=917 http://www.rawkam.com/?p=941

http://www.rawkam.com/?p=941

On Fri, Sep 10, 2010 at 1:11 AM, albert theboss alberttheb...@gmail.comwrote:

 Its easy only 

 tower of hanoi consist of three pegs peg A,peg B,peg C.
 which is used as BEG,AUX,END

 Let n be 5 for example...

 wat u r going to do is

 step 1 : move the top n-1 (4) disks from BEG to  AUX...
  in this case END will be used as auxiliary.

 step 2:  move the n th disk from BEG to END .
 use AUX as auxiliary in this case

 step 3: move the  n-1(4) disks from AUX to END that is moved in step 1
  use BEG as auxiliary in this step


 Actual code is

  void tower(int n,char beg,char aux,char end)
 {
if(n0)
 {
   tower(n-1,beg,end,aux);   //  move n-1 disks from beg to
 aux
printf(%c-%c,beg,aux,end);//equivalent to
 tower(1,beg,aux,end)move 1 disk from beg to end
tower(n-1,aux,beg,end)  //   move disks from aux to end
 }
 }

again that n-1 disks are moved to end which is called recursively.

 Still u have doubt???

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Google Interview Question

2010-09-15 Thread Gene
Some people have sent email asking what the stack looks like as the
program runs.  It's pretty silly to worry about this.  If you really
want to know, it's easy to modify the program to print a stack
trace.

Here you go:

#include stdio.h

// Buffer for strings of ().
char buf[1000];

typedef struct stack_record_s {
  struct stack_record_s *prev;
  int need, open, tail;
} STACK_RECORD;

void dump_state(STACK_RECORD *sr)
{
  int i = 0;
  printf(\nstate: buf=%.*s\n, sr-tail, buf);
  while (sr) {
printf(%d: need=%d, open=%d, tail=%d\n,
   i++, sr-need, sr-open, sr-tail);
sr = sr-prev;
  }
}

// Continue the printing of bracket strings.
//   need is the number of ('s still needed in our string.
//   open is tne number of ('s already used _without_ a matching ).
//   tail is the buffer location to place the next ) or (.
void cont(STACK_RECORD *sr)
{
  // Dump the entire program state as we enter the continuation.
  dump_state(sr);

  // If nothing needed or open, we're done.  Print.
  if (sr-need == 0  sr-open == 0) {
printf(output: %s\n, buf);
return;
  }

  // If still a need for (, add a ( and continue.
  if (sr-need  0) {
STACK_RECORD new_sr[1] = {{ sr, sr-need - 1, sr-open + 1, sr-
tail + 1 }};
buf[sr-tail] = '(';
cont(new_sr);
  }

  // If still an open (, add a ) and continue.
  if (sr-open  0) {
STACK_RECORD new_sr[1] = {{ sr, sr-need, sr-open - 1, sr-tail +
1 }};
buf[sr-tail] = ')';
cont(new_sr);
  }
}

void Brackets(int n)
{
  STACK_RECORD sr[1] = {{ NULL, n, 0, 0 }};
  cont(sr);
}

int main(void)
{
  Brackets(3);
  return 0;
}

When you run it, you get this output:

state: buf=
0: need=3, open=0, tail=0

state: buf=(
0: need=2, open=1, tail=1
1: need=3, open=0, tail=0

state: buf=((
0: need=1, open=2, tail=2
1: need=2, open=1, tail=1
2: need=3, open=0, tail=0

state: buf=(((
0: need=0, open=3, tail=3
1: need=1, open=2, tail=2
2: need=2, open=1, tail=1
3: need=3, open=0, tail=0

state: buf=((()
0: need=0, open=2, tail=4
1: need=0, open=3, tail=3
2: need=1, open=2, tail=2
3: need=2, open=1, tail=1
4: need=3, open=0, tail=0

state: buf=((())
0: need=0, open=1, tail=5
1: need=0, open=2, tail=4
2: need=0, open=3, tail=3
3: need=1, open=2, tail=2
4: need=2, open=1, tail=1
5: need=3, open=0, tail=0

state: buf=((()))
0: need=0, open=0, tail=6
1: need=0, open=1, tail=5
2: need=0, open=2, tail=4
3: need=0, open=3, tail=3
4: need=1, open=2, tail=2
5: need=2, open=1, tail=1
6: need=3, open=0, tail=0
output: ((()))

state: buf=(()
0: need=1, open=1, tail=3
1: need=1, open=2, tail=2
2: need=2, open=1, tail=1
3: need=3, open=0, tail=0

state: buf=(()(
0: need=0, open=2, tail=4
1: need=1, open=1, tail=3
2: need=1, open=2, tail=2
3: need=2, open=1, tail=1
4: need=3, open=0, tail=0

state: buf=(()()
0: need=0, open=1, tail=5
1: need=0, open=2, tail=4
2: need=1, open=1, tail=3
3: need=1, open=2, tail=2
4: need=2, open=1, tail=1
5: need=3, open=0, tail=0

state: buf=(()())
0: need=0, open=0, tail=6
1: need=0, open=1, tail=5
2: need=0, open=2, tail=4
3: need=1, open=1, tail=3
4: need=1, open=2, tail=2
5: need=2, open=1, tail=1
6: need=3, open=0, tail=0
output: (()())

state: buf=(())
0: need=1, open=0, tail=4
1: need=1, open=1, tail=3
2: need=1, open=2, tail=2
3: need=2, open=1, tail=1
4: need=3, open=0, tail=0

state: buf=(())(
0: need=0, open=1, tail=5
1: need=1, open=0, tail=4
2: need=1, open=1, tail=3
3: need=1, open=2, tail=2
4: need=2, open=1, tail=1
5: need=3, open=0, tail=0

state: buf=(())()
0: need=0, open=0, tail=6
1: need=0, open=1, tail=5
2: need=1, open=0, tail=4
3: need=1, open=1, tail=3
4: need=1, open=2, tail=2
5: need=2, open=1, tail=1
6: need=3, open=0, tail=0
output: (())()

state: buf=()
0: need=2, open=0, tail=2
1: need=2, open=1, tail=1
2: need=3, open=0, tail=0

state: buf=()(
0: need=1, open=1, tail=3
1: need=2, open=0, tail=2
2: need=2, open=1, tail=1
3: need=3, open=0, tail=0

state: buf=()((
0: need=0, open=2, tail=4
1: need=1, open=1, tail=3
2: need=2, open=0, tail=2
3: need=2, open=1, tail=1
4: need=3, open=0, tail=0

state: buf=()(()
0: need=0, open=1, tail=5
1: need=0, open=2, tail=4
2: need=1, open=1, tail=3
3: need=2, open=0, tail=2
4: need=2, open=1, tail=1
5: need=3, open=0, tail=0

state: buf=()(())
0: need=0, open=0, tail=6
1: need=0, open=1, tail=5
2: need=0, open=2, tail=4
3: need=1, open=1, tail=3
4: need=2, open=0, tail=2
5: need=2, open=1, tail=1
6: need=3, open=0, tail=0
output: ()(())

state: buf=()()
0: need=1, open=0, tail=4
1: need=1, open=1, tail=3
2: need=2, open=0, tail=2
3: need=2, open=1, tail=1
4: need=3, open=0, tail=0

state: buf=()()(
0: need=0, open=1, tail=5
1: need=1, open=0, tail=4
2: need=1, open=1, tail=3
3: need=2, open=0, tail=2
4: need=2, open=1, tail=1
5: need=3, open=0, tail=0

state: buf=()()()
0: need=0, open=0, tail=6
1: need=0, open=1, tail=5
2: need=1, open=0, tail=4
3: need=1, open=1, tail=3
4: need=2, open=0, tail=2
5: need=2, open=1, tail=1
6: need=3, open=0, tail=0
output: ()()()

On Sep 14,