Post by Justin ReardonPost by Bo HuPost by cd cs134/A03For the two functions
(define (bst-insert root key) ... )
(define (bst-search root key) ... )
I'm assuming the return types are void and boolean respectively?
I think you can return whatever you want.
If we can return anything, then how are the marmoset tests supposed to
work? Surely bst-search at least must return certain values? If bst-insert
does not require particular return values then presumably we cannot rely on
being able to build the tree in a functional manner, but we still haven't
been given an answer to that either.
I think providing us with some sample code from the scheme and ML
automated tests might help.
For example FingerTree in ML:
val testTree =
bst_insert(
bst_insert(
bst_insert(
bst_insert(
bst_insert(
bst_insert( Leaf, 5 ), 2 ), 8), 3), 4), 1 )
bst_search( testTree, 4 );
should have the following on standard out:
1234
For example FingerTree in Scheme:
( define testTree ( bst-insert( bst-insert( bst-insert( bst-insert(
bst-insert ( bst-insert null 5) 2) 8) 3) 4) 1) )
should have the following on standard out:
1234
( bst-search tree newValue )
Or maybe using a similar interface to testing the C program would be
easier to test. That way you won't have to worry about our interface.
IE for each test you would call:
ML: build_search( size, array, num)
Scheme: (build_search size array num)
Similar to C: void build_search(int _size, int *_array, int _num) ;
Cheers,
Joseph