[plt-scheme] Doubt Exercise 14.2.2 HTDP

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Mar 20 17:15:05 EDT 2009

Use (local ((define result-for-left-branch ...) (cond ...)))


On Mar 20, 2009, at 5:00 PM, Renato Dutra Luciano wrote:

> Olá de novo, muito obrigado pelas informacoes, meu codigo ficou  
> muito melhor e muito menor como vode pode ver.
> porem a minha duvida com relacao a minha chamada recursiva  
> persiste. continuo percorrendo a arvore duas vezes e que
> acredito nao ter necessidade. Gostaria muito de ajuda novamente.
>
> Hi again, thanks for the informations, my code turned better and  
> smaller like you can see.
> However my doubt about a self-referential persist. I continue  
> searching in the binary tree two times and
> I believe this is not needed (lines 52-54). Is there any suggestion?
>
> Thanks!
> Renato.
>
> > CC: plt-scheme at list.cs.brown.edu
> > From: matthias at ccs.neu.edu
> > Subject: Re: [plt-scheme] Doubt Exercise 14.2.2 HTDP
> > Date: Fri, 20 Mar 2009 11:47:40 -0400
> > To: renatoluciano at hotmail.com
> >
> >
> >
> > Renato, your program is missing the data definition for BTs  
> (though I
> > can infer it).
> >
> > You did not follow the design recipe to design your function. As a
> > result,
> > -- it works by accident
> > -- and it is FAR MORE complex than needed.
> >
> > Please go step by step. Design the template with these questions in
> > mind:
> >
> > 1. How many clauses are in the data definition
> > That's how many clauses I need in the COND
> > Formulate appropriate conditions to separate these things.
> >
> > 2. Which DD clauses introduce compound data
> > In the corresponding COND clauses, you need to write down
> > selector expressions
> >
> > 3. Which DD clauses use self-references, and which pieces are
> > involved?
> > Add recursive calls around the corresponding selector expressions.
> >
> > Then solve the problem as follows:
> >
> > A. Fill in the gaps in the non-recursive cases.
> > B. For the recursive cases:
> > -- what do the various expressions compute
> > -- how do you combine those results to get the final answers
> >
> > Good luck -- Matthias
> >
> >
> >
> >
> >
> >
> >
> > On Mar 19, 2009, at 5:06 PM, Renato Dutra Luciano wrote:
> >
> > > Hi! I am Renato from Brazil. I am studying the 'How to Design
> > > Programs'.
> > > In the Section 14 more specifically in the exercise 14.2.2 I have
> > > a doubt despite my tests are all passing.
> > > While searching for a element on the binary tree, using the
> > > function Boolean?, my recursive function (search-bt) does one more
> > > search than it should. (lines 49 - 54) Is there a better way???
> > >
> > > Thanks!
> > > Dutra Luciano, Renato.
> > > Veja mapas e encontre as melhores rotas para fugir do trânsito com
> > > o Live Search Maps! Experimente já!<14.2.2.exercise>
> > > _________________________________________________
> > > For list-related administrative tasks:
> > > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
>
> Diversão em dobro: compartilhe fotos enquanto conversa usando o  
> Windows Live Messenger.<14.2.2.exercise>



Posted on the users mailing list.