Re: [algogeeks] Is max distance between two leaves(diameter) in a tree is equal to max distance between any two node in that tree??

2012-06-25 Thread atul anand
consider a case where tree is right skewed or left skewed , in dat case max
distance b/w two node found are root and leftmost or rightmost node(left
or right skewed) . so its not alwayzz true

On Sun, Jun 24, 2012 at 5:08 PM, Navin Kumar algorithm.i...@gmail.comwrote:


  --
 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/-/xM3mGdcfvi4J.
 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 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 algogeeks@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] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread Roshan
Few Months back I found the problem 
on Code Sprint 
1/x + 1/y = 1/N! (N factorial).   For large value of N 
we have to find the par of (X,Y) which satisfy the equation 
my sol was slow , 
can any pleas help me .

Thanks
Kumar Vishal 

-- 
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/-/PeqVSr7OlFsJ.
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] [amazon ] Finding Sub segment

2012-06-25 Thread Navin Kumar
please provide some good data structure  to solve this problem:

http://www.careercup.com/question?id=14062676

-- 
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/-/WZiRDVnMKQYJ.
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread prakash y
2! - x=y=4
3! - x=y=12
4! - x=y=48
5! - x=y=240
6! - x=y=1440
I don't have proof to prove x = y always.
But if x=y, then the answer should be x=y=2*n!

On Mon, Jun 25, 2012 at 5:04 PM, Roshan kumar...@gmail.com wrote:

 Few Months back I found the problem
 on Code Sprint
 1/x + 1/y = 1/N! (N factorial).   For large value of N
 we have to find the par of (X,Y) which satisfy the equation
 my sol was slow ,
 can any pleas help me .

 Thanks
 Kumar Vishal

 --
 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/-/PeqVSr7OlFsJ.
 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 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 algogeeks@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] Abridged summary of algogeeks@googlegroups.com - 10 Messages in 8 Topics

2012-06-25 Thread amit singh
sourabh singh, i think problem in your code may arise due to term (m/a
-n/a) ,instead it should be m/a -(n-1)/a .
there may be some other problem  also .but this can be one of them

On Mon, Jun 25, 2012 at 5:10 PM,  algogeeks@googlegroups.com wrote:
   Today's Topic Summary

 Group: http://groups.google.com/group/algogeeks/topics

 Is max distance between two leaves(diameter) in a tree is equal to max
 distance between any two node in that tree?? [1 Update]
 Adobe interview question [1 Update]
 4Sum [1 Update]
 spoj problem EASYMATH [3 Updates]
 Find the Max from each sub-array of size k [1 Update]
 Lucky Draw - longest increasing sub sequence in a circular arrangement [1
 Update]
 Reverse Queue [1 Update]
 Find peak element in log(n) [1 Update]

  Is max distance between two leaves(diameter) in a tree is equal to max
 distance between any two node in that tree??

 atul anand atul.87fri...@gmail.com Jun 25 12:48PM +0530

 consider a case where tree is right skewed or left skewed , in dat case max
 distance b/w two node found are root and leftmost or rightmost node(left
 or right skewed) . so its not alwayzz true

 ...more

  Adobe interview question

 himanshu kansal himanshukansal...@gmail.com Jun 25 09:12AM +0530

 @rahul: the ques itself says that we have to implement abstract
 class*without
 * using pure virtual function...


 --

 Regards
 Himanshu Kansal
 Msc Comp. sc.
 (University of Delhi)
 ...more

  4Sum

 shady sinv...@gmail.com Jun 25 12:42AM +0530

 @hemesh, amol = correct solutions

 ABCDEF another problem on SPOJ, incase people want to try.

 ...more

  spoj problem EASYMATH

 Sourabh Singh singhsourab...@gmail.com Jun 24 07:40AM -0700

 please suggest something :

 Problem :
 http://www.spoj.pl/problems/EASYMATH/

 C++ code :
 http://ideone.com/r2OSb
 was getting wrong ans due to over flow i think in LCM() for big prime's i
 guess. ...more

 Hassan Monfared hmonfa...@gmail.com Jun 24 07:29PM +0430

 use  return (a/gcd(a,b)*b instead 

 ...more

 shady sinv...@gmail.com Jun 25 12:35AM +0530

 dont post codes, ask whether your algorithm is correct or not.

 ...more

  Find the Max from each sub-array of size k

 rajesh pandey rajesh.pandey.i...@gmail.com Jun 24 05:10PM +0530

 can find one more solution in my blog
 http://pandey123.wordpress.com/

 check it... and tell me if you have any doubt...

 ...more

  Lucky Draw - longest increasing sub sequence in a circular arrangement

 sachin goyal sachingoyal@gmail.com Jun 24 05:42AM -0700

 http://www.codechef.com/problems/D2/

 Please suggest some good algorithm for this problem
 ...more

  Reverse Queue

 deepikaanand swinyanand...@gmail.com Jun 24 08:53AM -0700

 code:-
 http://ideone.com/yMQSK
 ...more

  Find peak element in log(n)

 Anshul Agarwal anshul.agarwa...@gmail.com Jun 24 07:11PM +0530

 can any one expain for 2-D??


 ...more

 You received this message because you are subscribed to the Google Group
 algogeeks.
 You can post via email.
 To unsubscribe from this group, send an empty message.
 For more options, visit this group.

 --
 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 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 algogeeks@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] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread Kishore
This is from interviewstreet named with equations

On Mon, Jun 25, 2012 at 11:19 AM, prakash y yprakash@gmail.com wrote:

 2! - x=y=4
 3! - x=y=12
 4! - x=y=48
 5! - x=y=240
 6! - x=y=1440
 I don't have proof to prove x = y always.
 But if x=y, then the answer should be x=y=2*n!

 On Mon, Jun 25, 2012 at 5:04 PM, Roshan kumar...@gmail.com wrote:

 Few Months back I found the problem
 on Code Sprint
 1/x + 1/y = 1/N! (N factorial).   For large value of N
 we have to find the par of (X,Y) which satisfy the equation
 my sol was slow ,
 can any pleas help me .

 Thanks
 Kumar Vishal

 --
 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/-/PeqVSr7OlFsJ.
 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 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 algogeeks@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 algogeeks@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] 1/x + 1/y = 1/(n factorial)

2012-06-25 Thread Kumar Vishal
 
We have to find number of Pair(x,y)
which will satisfy the eq:
1/x + 1/y = 1/(n factorial)

for large 0  N  10 ^ 4 N is integer 
Its problem from Code Sprint 
I tried to solve it by taking LOG but the sol 
was very slow , can any one please help 

Thanks
Kumar Vishal 

-- 
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/-/9SPU8dameBgJ.
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Is max distance between two leaves(diameter) in a tree is equal to max distance between any two node in that tree??

2012-06-25 Thread Mohit Khanna
What would be the diameter in case of a left skewed or right skewed tree?


On Mon, Jun 25, 2012 at 12:48 PM, atul anand atul.87fri...@gmail.comwrote:

 consider a case where tree is right skewed or left skewed , in dat case
 max distance b/w two node found are root and leftmost or rightmost
 node(left  or right skewed) . so its not alwayzz true

 On Sun, Jun 24, 2012 at 5:08 PM, Navin Kumar algorithm.i...@gmail.comwrote:


  --
 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/-/xM3mGdcfvi4J.
 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 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 algogeeks@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 algogeeks@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] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread Kumar Vishal
@Prakash
   The Pattern given by u is because factorial (n) is always *even *so u
can always divide them
   in two equal part .
   what about
   1/6= 1/8 + 1/24( 6  = factorial (3))

On Mon, Jun 25, 2012 at 11:24 PM, Kishore kkishoreya...@gmail.com wrote:

 This is from interviewstreet named with equations


 On Mon, Jun 25, 2012 at 11:19 AM, prakash y yprakash@gmail.comwrote:

 2! - x=y=4
 3! - x=y=12
 4! - x=y=48
 5! - x=y=240
 6! - x=y=1440
 I don't have proof to prove x = y always.
 But if x=y, then the answer should be x=y=2*n!

 On Mon, Jun 25, 2012 at 5:04 PM, Roshan kumar...@gmail.com wrote:

 Few Months back I found the problem
 on Code Sprint
 1/x + 1/y = 1/N! (N factorial).   For large value of N
 we have to find the par of (X,Y) which satisfy the equation
 my sol was slow ,
 can any pleas help me .

 Thanks
 Kumar Vishal

 --
 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/-/PeqVSr7OlFsJ.
 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 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 algogeeks@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 algogeeks@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.




-- 
Regards
Kumar Vishal
_
*http://wethecommonpeople.wordpress.com/   *
*h**ttp://kumartechnicalarticles.wordpress.com/http://kumartechnicalarticles.wordpress.com/
*
_

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread Kumar Vishal
   Sorry My Mistake *Number of pairs should be OUTPUT...*

On Mon, Jun 25, 2012 at 8:49 PM, prakash y yprakash@gmail.com wrote:

 2! - x=y=4
 3! - x=y=12
 4! - x=y=48
 5! - x=y=240
 6! - x=y=1440
 I don't have proof to prove x = y always.
 But if x=y, then the answer should be x=y=2*n!

 On Mon, Jun 25, 2012 at 5:04 PM, Roshan kumar...@gmail.com wrote:

 Few Months back I found the problem
 on Code Sprint
 1/x + 1/y = 1/N! (N factorial).   For large value of N
 we have to find the par of (X,Y) which satisfy the equation
 my sol was slow ,
 can any pleas help me .

 Thanks
 Kumar Vishal

 --
 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/-/PeqVSr7OlFsJ.
 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 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 algogeeks@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.




-- 
Regards
Kumar Vishal
_
*http://wethecommonpeople.wordpress.com/   *
*h**ttp://kumartechnicalarticles.wordpress.com/http://kumartechnicalarticles.wordpress.com/
*
_

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Inorder Iterative code for printing paths

2012-06-25 Thread Nishant Pandey
thiss is iterative inorder  code i am using for printing all the paths of
the Btree .

but i am not able to manipulate the lengths properly when its perform pop
up so that i
can print the paths properly ..

Can any one help by modifying the changes in this code .



void inorder(struct node *root)
{
stackstruct node*stack_temp;

struct node *current,*temp;
int path[20];
int i =0 ,j=0;
if(!root)return ;

current=root;
bool flag=false;
//bool ctrl=false;
while(!flag)
{

if(current)
{
//coutcurrent-dataendl;
stack_temp.push(current);
path[i++]=current-data;
if(current-left == NULL  current-right == NULL)
{
for(j=0;ji;j++)
coutpath[j] ;
//i--;

}

coutendl;
current=current-left;

}
else
{
if(stack_temp.empty())
{
flag=true;
}
else
{
current=stack_temp.top();
stack_temp.pop();

i--;


//if(current-right)
//coutcurrent-dataendl;
current=current-right;
if(current)
i++;
}

}

}


}



-- 
Cheers,

Nishant Pandey |Specialist Tools Development  |
npan...@google.comgvib...@google.com |
+91-9911258345

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [amazon ] Finding Sub segment

2012-06-25 Thread atul anand
http://www.leetcode.com/2010/11/finding-minimum-window-in-s-which.html

On 6/25/12, Navin Kumar algorithm.i...@gmail.com wrote:
 please provide some good data structure  to solve this problem:

 http://www.careercup.com/question?id=14062676

 --
 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/-/WZiRDVnMKQYJ.
 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 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 algogeeks@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] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread prakash y
@Vishal,
If the output should be the total no.of pairs, then i think there are
infinite no.of such pairs. but not sure.
Can someone provide me the link to the actual problem and some analysis of
solution?

Thanks,
~Prakash.

On Mon, Jun 25, 2012 at 9:45 PM, Kumar Vishal kumar...@gmail.com wrote:

Sorry My Mistake *Number of pairs should be OUTPUT...*


 On Mon, Jun 25, 2012 at 8:49 PM, prakash y yprakash@gmail.com wrote:

 2! - x=y=4
 3! - x=y=12
 4! - x=y=48
 5! - x=y=240
 6! - x=y=1440
 I don't have proof to prove x = y always.
 But if x=y, then the answer should be x=y=2*n!

 On Mon, Jun 25, 2012 at 5:04 PM, Roshan kumar...@gmail.com wrote:

 Few Months back I found the problem
 on Code Sprint
 1/x + 1/y = 1/N! (N factorial).   For large value of N
 we have to find the par of (X,Y) which satisfy the equation
 my sol was slow ,
 can any pleas help me .

 Thanks
 Kumar Vishal

 --
 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/-/PeqVSr7OlFsJ.
 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 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 algogeeks@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.




 --
 Regards
 Kumar Vishal
 _
 *http://wethecommonpeople.wordpress.com/   *
 *h**ttp://kumartechnicalarticles.wordpress.com/http://kumartechnicalarticles.wordpress.com/
 *
 _


  --
 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 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 algogeeks@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.