content="Data-structures and algorithms in Standard ML. Notes from a lecture course given by Michael Fourman at the University of West Australia, Spring 1994." /> rel="start" type="text/html" href="/mfourman/index.html" title="Michael Fourman" /> Solutions – Practical 1

Solutions – Practical 1

Michael P. Fourman

October 31, 2006

This practical should have been straightforward, once you got to grips with the editor, Unix, and interaction with the ML system.

A simple answer to Question 2 would be

fun FF 0 = 1  
  | FF 1 = 3  
  | FF 2 = 5  
  | FF n = 1 + FF(n-1) + FF(n-3)

But this would take aeons to compute FF(200), so the iterative version given is necessary.

Since there was some confusion over what was intended (despite the fact that the instructions were clear), answers that counted internal nodes, rather than nodes, were also marked correct.

©Michael Fourman 1994-2006