# Scheme RSR5

All problems are to be solved using R5RS within drracket,

no vectors, no strings, no assignment ...

Question:

; For this problem, we will think of 0 as a convenient substitute for a left bracket,

; and 1 as a convenient substitute for a right bracket.

; A sequence of 0s and 1s is said to be balanced if (i) every 0 is later

; closed by some 1, and (ii) every 1 closes a previous 0.

; Thus ((0 1)) is the list of all balanced sequences of length 2, and

; ( (0 0 1 1) (0 1 0 1) ) is a list of all balanced sequences of

; length 4

; Assuming n is a positive even integer, write and prove correct

; a function bal so that (bal n) returns a list - without duplicates -

; of all balanced sequences of 0s and 1s of length n. Your program

; should be as efficient as you can reasonably make it: at the very least, it should not generate

; any unbalanced sequences in the course of computing the final result.

; (hint: you will need a carefully considered recursive design and several

; auxiliary functions; I suggest that you use structural induction)

Tentang Majikan:
( 9 ulasan ) South Ozone Park, United States

ID Projek: #28200332