Re: [algogeeks] Re: Amazon Placement Question

2010-08-02 Thread padmanaban sahadevan
try this code guys

i think there is redundancy in condition checking.

if so correct me...

#includestdio.h
struct node
{
int data;
struct node* left;
struct node* right;
struct node* sibling;
};
void connectHorizontal(struct node* root)
{
if(root == NULL)
return root;
else if(root-left==NULL  root-right ==NULL)
return root;
else
{
if(root-left !=NULL)
connectHorizontal(root-left);
if(root-right!=NULL)
connectHorizontal(root-right);
if(root-left!=NULL)
{
root-left-sibling = (root-right ? root-right :
(root-sibling-left ? root-sibling-left : (root-sibling-right ?
root-sibling-right : NULL)));
}
if(root-right!=NULL)
{
root-right-sibling = (root-sibling-left ?
root-sibling-left : (root-sibling-right ? root-sibling-right : NULL));
}
}
}

-- 
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] recursive

2010-07-29 Thread padmanaban sahadevan
void levelordertraversal(struct node* root,height)
{
 int i=0;
   for(i=1;i=height(root);i++
  printlevel(root,i);
}
void printlevel(struct node *root, level)
{
 if(root == null)
return;
 else if(level==1)
 printf(%d,root-data);
 else if(level1)
 {
 printlevel(root-left,level-1);
 printlevel(root-right,level-1);
 }
}

-- 
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] pointer and array

2010-07-25 Thread padmanaban sahadevan
@tarak mehta:  if u wanna understand, try passing a char array to a function
n do de same...

On Sun, Jul 25, 2010 at 9:59 AM, Manjunath Manohar manjunath.n...@gmail.com
 wrote:


 @Apporve... yeah u r right :)sizeof ptr is always 2 in 16 bit compilers,
 i.e, the sizeof an address is 2.and the sizeof(int)=2..i.e
 sizeof(*arr)=2..hope u got it now..

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