@kaushik where are you creating explicit stack ? It has to be outside
inorder(Root) , right ?
If yes , then you can use only a count and that should work .  Make
kth bit of count = 1 , rest all 0.
Just  before printing in Inorder , right shift count and when it
becomes ZERO , that's the value you are looking for.

If no  , please explain bit more in detail about it.

On May 16, 9:44 am, satwik krishna <sathi...@gmail.com> wrote:
> @Rohit
> Can u pass on thje link of morris inorder
>
> On 5/15/10, Rohit Saraf <rohit.kumar.sa...@gmail.com> wrote:
>
>
>
>
>
> > there  is something called morris inorder traversal.
> > credits to donald knuth
>
> > On 5/15/10, kaushik sur <kaushik....@gmail.com> wrote:
> > > Hi Friends
>
> > > I have encountered the question in sites - "Given a Binary Search
> > > Tree, write a program to print the kth smallest element without using
> > > any static/global variable. You can't pass the value k to any function
> > > also."
>
> > > I have tried my hands using  explicit stack for inorder and keeping a
> > > non-static count variable.
>
> > > I welcome any better solution, time and space efficient.
>
> > > Best Regards
> > > Kaushik Sur
>
> > > --
> > > 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<algogeeks%2bunsubscr...@googlegroups.com>
> > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
>
> > --
> > --------------------------------------------------
> > Rohit Saraf
> > Second Year Undergraduate,
> > Dept. of Computer Science and Engineering
> > IIT Bombay
> >http://www.cse.iitb.ac.in/~rohitfeb14
>
> > --
> > 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<algogeeks%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 
> athttp://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.

Reply via email to