{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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 Right Arrow Icon bookmark
Ask a homework question - tutors are online