[plt-scheme] Doubt Exercise 14.2.2 HTDP

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Mar 20 11:47:40 EDT 2009

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  
  -- it works by accident
  -- and it is FAR MORE complex than needed.

Please go step by step. Design the template with these questions in  

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

Posted on the users mailing list.