@surender: in the while loop all the nodes are being checked...please tell
me where u r stuck???

On Mon, Jul 4, 2011 at 2:13 PM, surender sanke <surend...@gmail.com> wrote:

> chk_bst doesnt works as its checking only for its immediate child's values.
> i think inorder non decreasing sequence checking would require here which
> is iteratively programmed
>
> surender
>
> On Thu, Jun 30, 2011 at 4:05 PM, Apoorve Mohan <apoorvemo...@gmail.com>wrote:
>
>> 1.
>>
>> int chk_bst(node *root)
>> {
>>  if(root)
>>  {
>>    enqueue(root);
>>    while(!isempty())
>>    {
>>     p=dequeue();
>>
>>     if(p->left)
>>     {
>>      if(!(p->left->data < p->data))
>>      return 0;
>>      enqueue(p->left);
>>     }
>>
>>     if(p->right)
>>     {
>>      if(!(p->right->data >= p->data))
>>      return 0;
>>      enqueue(p->right);
>>     }
>>    }
>>   }
>> return 1;
>> }
>>
>>
>>
>> 2.
>>
>> void mirror(node **root)
>> {
>>
>> if(root)
>> {
>>  enqueue(*root);
>>  while(!isempty())
>>  {
>>   *p = dequeue();
>>   if(*p->left)
>>   enqueue(*p->left);
>>   if(*p->right)
>>   enqueue(*p-right);
>>   swap(*p->left,*p->right);
>>  }
>> }
>> }
>>
>>
>> On Thu, Jun 30, 2011 at 2:12 PM, vikas <mehta...@gmail.com> wrote:
>>
>>> for 1 i did implement exactly the same algorithms.
>>>
>>> and for 2 i donot know why but at that time i was not able to implement
>>> it iteratively and hense implemented its recursive version only.
>>>
>>> --
>>> 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/-/hJswdQGammMJ.
>>>
>>> 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
>>
>> Apoorve Mohan
>>
>>
>>  --
>> 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

Apoorve Mohan

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

Reply via email to