Re: [algogeeks] BST question

2011-11-11 Thread UTKARSH SRIVASTAV
correct me if I am wrong

#includestdio.h

struct node
{
int data;
struct node *left;
struct node * right;
}*root;

int sum(int s,struct node *p,int ar[],int l)
{
if(p == NULL )
{
return 0;
}
if(p-left == NULL  p-right == NULL)
{
if( s - p-data == 0)
{
ar[l++] = p-data;
int i;
for( i = 0 ;i  l ;i++)
{
printf(%d ,ar[i]);
}
printf(\n);
}

}
ar[l++] = p-data;
sum(s - p-data, p-left , ar , l);
sum(s - p-data, p-right , ar, l);
return 0;
}

struct node * getnode(int k)
{
struct node *temp = malloc(sizeof(struct node));
temp-data = k;
temp-left= NULL;
temp-right = NULL;
return temp;
}

main()
{
int ar[50],value;
root = getnode(5);
root-left= getnode(2);
root-right = getnode(2);
root-left-left = getnode(7);
root-left-right = getnode(8);
root-right-left = getnode(3);
root-right-right = getnode(7);
value = 14;
sum(value,root,ar,0);
return 0;
}

On Fri, Nov 11, 2011 at 12:38 PM, aniket chatterjee aniket...@gmail.comwrote:

 Write a recursive function that will store each root to leaf path in an
 array. Now for each root to leaf path find the subarray which sums up to X.

 On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote:

 Hi All,

 Please give me the solution of this problem.

 A binary tree and a number X is given. Find all the paths(not necessarily
 starting from root) such that the sum equals X.


 Regards,
 Aman.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to
 continue that counts!

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




-- 
*UTKARSH SRIVASTAV
CSE-3
B-Tech 3rd Year
@MNNIT ALLAHABAD*

-- 
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] BST question

2011-11-11 Thread aniket chatterjee
As far as I understand, your solution will always contain the path that
essentially start from root. But the actual problem states that the path
may not necessarily start from root.

On Fri, Nov 11, 2011 at 1:21 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:


 correct me if I am wrong

 #includestdio.h

 struct node
 {
 int data;
 struct node *left;
 struct node * right;
 }*root;

 int sum(int s,struct node *p,int ar[],int l)
 {
 if(p == NULL )
 {
 return 0;
 }
 if(p-left == NULL  p-right == NULL)
 {
 if( s - p-data == 0)
 {
 ar[l++] = p-data;
 int i;
 for( i = 0 ;i  l ;i++)
 {
 printf(%d ,ar[i]);
 }
 printf(\n);
 }

 }
 ar[l++] = p-data;
 sum(s - p-data, p-left , ar , l);
 sum(s - p-data, p-right , ar, l);
 return 0;
 }

 struct node * getnode(int k)
 {
 struct node *temp = malloc(sizeof(struct node));
 temp-data = k;
 temp-left= NULL;
 temp-right = NULL;
 return temp;
 }

 main()
 {
 int ar[50],value;
 root = getnode(5);
 root-left= getnode(2);
 root-right = getnode(2);
 root-left-left = getnode(7);
 root-left-right = getnode(8);
 root-right-left = getnode(3);
 root-right-right = getnode(7);
 value = 14;
 sum(value,root,ar,0);
 return 0;

 }

 On Fri, Nov 11, 2011 at 12:38 PM, aniket chatterjee 
 aniket...@gmail.comwrote:

 Write a recursive function that will store each root to leaf path in an
 array. Now for each root to leaf path find the subarray which sums up to X.

 On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote:

 Hi All,

 Please give me the solution of this problem.

 A binary tree and a number X is given. Find all the paths(not
 necessarily starting from root) such that the sum equals X.


 Regards,
 Aman.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to
 continue that counts!

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




 --
 *UTKARSH SRIVASTAV
 CSE-3
 B-Tech 3rd Year
 @MNNIT ALLAHABAD*


  --
 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] BST question

2011-11-11 Thread aniket chatterjee
And also your solution prints the root to leaf path that sums up to X. But
the path may not contain root as well as leaf also. May be some
intermediate 4 nodes (from root to leaf path)sums up to X. Your code doesnt
provide the solution for that scenario.

On Fri, Nov 11, 2011 at 2:53 PM, aniket chatterjee aniket...@gmail.comwrote:

 As far as I understand, your solution will always contain the path that
 essentially start from root. But the actual problem states that the path
 may not necessarily start from root.

 On Fri, Nov 11, 2011 at 1:21 PM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:


 correct me if I am wrong

 #includestdio.h

 struct node
 {
 int data;
 struct node *left;
 struct node * right;
 }*root;

 int sum(int s,struct node *p,int ar[],int l)
 {
 if(p == NULL )
 {
 return 0;
 }
 if(p-left == NULL  p-right == NULL)
 {
 if( s - p-data == 0)
 {
 ar[l++] = p-data;
 int i;
 for( i = 0 ;i  l ;i++)
 {
 printf(%d ,ar[i]);
 }
 printf(\n);
 }

 }
 ar[l++] = p-data;
 sum(s - p-data, p-left , ar , l);
 sum(s - p-data, p-right , ar, l);
 return 0;
 }

 struct node * getnode(int k)
 {
 struct node *temp = malloc(sizeof(struct node));
 temp-data = k;
 temp-left= NULL;
 temp-right = NULL;
 return temp;
 }

 main()
 {
 int ar[50],value;
 root = getnode(5);
 root-left= getnode(2);
 root-right = getnode(2);
 root-left-left = getnode(7);
 root-left-right = getnode(8);
 root-right-left = getnode(3);
 root-right-right = getnode(7);
 value = 14;
 sum(value,root,ar,0);
 return 0;

 }

 On Fri, Nov 11, 2011 at 12:38 PM, aniket chatterjee 
 aniket...@gmail.comwrote:

 Write a recursive function that will store each root to leaf path in an
 array. Now for each root to leaf path find the subarray which sums up to X.

 On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote:

 Hi All,

 Please give me the solution of this problem.

 A binary tree and a number X is given. Find all the paths(not
 necessarily starting from root) such that the sum equals X.


 Regards,
 Aman.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to
 continue that counts!

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




 --
 *UTKARSH SRIVASTAV
 CSE-3
 B-Tech 3rd Year
 @MNNIT ALLAHABAD*


  --
 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] BST question

2011-11-10 Thread AMAN AGARWAL
Hi All,

Please give me the solution of this problem.

A binary tree and a number X is given. Find all the paths(not necessarily
starting from root) such that the sum equals X.


Regards,
Aman.

-- 
AMAN AGARWAL
Success is not final, Failure is not fatal: It is the courage to continue
that counts!

-- 
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] BST question

2011-11-10 Thread aniket chatterjee
Write a recursive function that will store each root to leaf path in an
array. Now for each root to leaf path find the subarray which sums up to X.

On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL mnnit.a...@gmail.com wrote:

 Hi All,

 Please give me the solution of this problem.

 A binary tree and a number X is given. Find all the paths(not necessarily
 starting from root) such that the sum equals X.


 Regards,
 Aman.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to continue
 that counts!

 --
 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] BST Question

2011-07-30 Thread Mani Bharathi
connect all sibling nodes of a binary search tree

-- 
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/-/GWAhIi6vaxAJ.
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] BST Question

2011-07-30 Thread saurabh singh
please give an example.

On Sat, Jul 30, 2011 at 12:10 PM, Mani Bharathi manibharat...@gmail.comwrote:

 connect all sibling nodes of a binary search tree

 --
 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/-/GWAhIi6vaxAJ.
 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.




-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD

-- 
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] BST Question

2011-07-30 Thread aditi garg
Do u mean something like level order traversal??

On Sat, Jul 30, 2011 at 12:11 PM, saurabh singh saurab...@gmail.com wrote:

 please give an example.


 On Sat, Jul 30, 2011 at 12:10 PM, Mani Bharathi 
 manibharat...@gmail.comwrote:

 connect all sibling nodes of a binary search tree

 --
 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/-/GWAhIi6vaxAJ.
 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD



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




-- 
Aditi Garg
Undergraduate Student
Electronics  Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

-- 
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] BST Question

2010-10-24 Thread Praveen Baskar
oh ya thanks now i got it

On Sun, Oct 24, 2010 at 9:54 AM, preetika tyagi preetikaty...@gmail.comwrote:

 @Praveen- In this case, we will not ignore the right subtree of the root
 (-10, which is less than zero) while traversing the tree.


 On Sat, Oct 23, 2010 at 9:06 PM, Praveen Baskar 
 praveen200...@gmail.comwrote:

 i think it is possible nishaanth
 please do take a look at this example

 -10
/\
  -11   8
 /\
   -5 10
  -5 is greater than -10


 On Sat, Oct 23, 2010 at 11:19 PM, nishaanth nishaant...@gmail.comwrote:

 @Praveenit is not possible..in a BST *all the nodes* on the right
 subtree are greater than the node :)


 On Sat, Oct 16, 2010 at 3:26 PM, Praveen Baskar praveen200...@gmail.com
  wrote:

 @nishaanth: wat if the left child of the right node has a negative value


 On Thu, Oct 14, 2010 at 11:12 AM, nishaanth nishaant...@gmail.comwrote:



 Just see the value of the node at every point, if it is greater than
 zero dont recurse the right sub-tree, as simple as it is.print the node u
 inspected if it is less than zero.




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




 --
 By B. Praveen

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




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




 --
 By B. Praveen

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




-- 
By B. Praveen

-- 
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] BST Question

2010-10-23 Thread nishaanth
@Praveenit is not possible..in a BST *all the nodes* on the right
subtree are greater than the node :)

On Sat, Oct 16, 2010 at 3:26 PM, Praveen Baskar praveen200...@gmail.comwrote:

 @nishaanth: wat if the left child of the right node has a negative value

 On Thu, Oct 14, 2010 at 11:12 AM, nishaanth nishaant...@gmail.com wrote:



 Just see the value of the node at every point, if it is greater than zero
 dont recurse the right sub-tree, as simple as it is.print the node u
 inspected if it is less than zero.




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




 --
 By B. Praveen

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




-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

-- 
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] BST Question

2010-10-23 Thread Praveen Baskar
i think it is possible nishaanth
please do take a look at this example

-10
   /\
 -11   8
/\
  -5 10
 -5 is greater than -10


On Sat, Oct 23, 2010 at 11:19 PM, nishaanth nishaant...@gmail.com wrote:

 @Praveenit is not possible..in a BST *all the nodes* on the right
 subtree are greater than the node :)


 On Sat, Oct 16, 2010 at 3:26 PM, Praveen Baskar 
 praveen200...@gmail.comwrote:

 @nishaanth: wat if the left child of the right node has a negative value

 On Thu, Oct 14, 2010 at 11:12 AM, nishaanth nishaant...@gmail.comwrote:



 Just see the value of the node at every point, if it is greater than
 zero dont recurse the right sub-tree, as simple as it is.print the node u
 inspected if it is less than zero.




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




 --
 By B. Praveen

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




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




-- 
By B. Praveen

-- 
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] BST Question

2010-10-23 Thread preetika tyagi
@Praveen- In this case, we will not ignore the right subtree of the root
(-10, which is less than zero) while traversing the tree.

On Sat, Oct 23, 2010 at 9:06 PM, Praveen Baskar praveen200...@gmail.comwrote:

 i think it is possible nishaanth
 please do take a look at this example

 -10
/\
  -11   8
 /\
   -5 10
  -5 is greater than -10


 On Sat, Oct 23, 2010 at 11:19 PM, nishaanth nishaant...@gmail.com wrote:

 @Praveenit is not possible..in a BST *all the nodes* on the right
 subtree are greater than the node :)


 On Sat, Oct 16, 2010 at 3:26 PM, Praveen Baskar 
 praveen200...@gmail.comwrote:

 @nishaanth: wat if the left child of the right node has a negative value

 On Thu, Oct 14, 2010 at 11:12 AM, nishaanth nishaant...@gmail.comwrote:



 Just see the value of the node at every point, if it is greater than
 zero dont recurse the right sub-tree, as simple as it is.print the node u
 inspected if it is less than zero.




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




 --
 By B. Praveen

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




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




 --
 By B. Praveen

 --
 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] BST Question

2010-10-16 Thread Praveen Baskar
@nishaanth: wat if the left child of the right node has a negative value

On Thu, Oct 14, 2010 at 11:12 AM, nishaanth nishaant...@gmail.com wrote:



 Just see the value of the node at every point, if it is greater than zero
 dont recurse the right sub-tree, as simple as it is.print the node u
 inspected if it is less than zero.




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

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




-- 
By B. Praveen

-- 
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] BST Question

2010-10-13 Thread Narsimha Raju
HI
   A BST is given you need to print all the negative numbers.

Sol: Inorder traversal will work. but i want to ignore the right sub trees
based on the value at the root. (i.e efficient sol)

-- 
Regards,
C. Narsimha Raju
MS, IIIT Hyderabad.
http://research.iiit.ac.in/~narsimha_raju/

-- 
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] BST Question

2010-10-13 Thread nishaanth

 Just see the value of the node at every point, if it is greater than zero
dont recurse the right sub-tree, as simple as it is.print the node u
inspected if it is less than zero.




-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

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