{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# ps3 - Massachusetts Institute of Technology 16.410-13...

This preview shows pages 1–2. Sign up to view the full content.

Massachusetts Institute of Technology 16.410-13 Principles of Autonomy and Decision Making Assignment #3, tutorial. Due: LEC #6 Problem PS.3.1.1: List Creation Write a simple Scheme function, fill-list, that takes as parameters an integer, n, (which is greater than or equal to 1) and an element that can be of any type. The function should create a list of length n, with each item in the list being the element. For example, (fill-list 1 'x) => (x) (fill-list 5 'x) => (x x x x x) (fill-list 2 '(a b)) => ((a b) (a b)) Problem PS.3.1.2: Tree Creation Write a simple Scheme function, fill-tree, that takes as parameters an integer, depth, (which is greater than or equal to 2) and an integer, node-index. The function should create a binary tree of the specified depth. The format of the tree should be (node-index (left-child right-child)), where left-child and right-child may themselves be trees (this is a recursive definition). At the deepest level of the tree, left-child and right-child are just

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

ps3 - Massachusetts Institute of Technology 16.410-13...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online