Re: [algogeeks] Find The Kth min in a binary search tree

2010-07-25 Thread Priyanka Chatterjee
void kSmallestBST(struct node * root,int k){

static int count=0;

if(!root) return;
kSmallestBST(root->left,k);
if(++count==k) {coutright,k);

}




-- 
Thanks & Regards,
Priyanka Chatterjee
Final Year Undergraduate Student,
Computer Science & Engineering,
National Institute Of Technology,Durgapur
India
http://priyanka-nit.blogspot.com/

-- 
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] Find The Kth min in a binary search tree

2010-07-25 Thread Manjunath Manohar
void kthsmallest(Tree *node,int k)
{
   static int count=0;
   if(node!=NULL && count!=k)
   {
   kthsmallest(node->left);
   printf("\nKth Smallest - - %d\n",node->data);
   kthsmallest(node->right);
   }
}

-- 
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] Find The Kth min in a binary search tree

2010-07-25 Thread Debanjan Ghosh
int FindKthSmallest(TreePointer ptr){

int count=0;
if(ptr){
FindKthSmallest(ptr->leftchild);
count++;
FindKthSmallest(ptr->rightchild);

}
return count;
}

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