Comp 210
50-minute in-class quiz
Please write your solutions in the space provided.
Insert-5
that takes a single list l
as input.
l
is sorted in ascending order, complete
your function Insert-5
to return a sorted list
containing all the elements of l
and the number 5.
In other words, insert 5 in its proper location in l
.
<dtree> := (nochild name) | (onechild name only) | (twochild name first second)where
name
is a symbol and
only
, first
, and second
are dtrees.
define-structure
statements that can be used to
implement this data type in Scheme. List the
constructors, predicates, and selectors created by these
define-structures.
size
that takes as input a descendant tree t
.
size
returns
the number of people in the descendant tree t
.
<color> := (green) | (yellow) | (red) <condition> := (wet) | (dry)
define-structure
statements that can be used to
implement these two data types in Scheme. List the
constructors, predicates, and selectors created by these
define structures.
proceed?
that
takes as input a variable signal
of type color
and a variable weather
of type condition.