Assignment 4

  1. Convert the following function definitions into tail-recursive ones.
  2. Define in F# the following functions on lists.
  3. Assume a set is represented as a list without duplicates. Define the following functions on sets:
  4. Write a function that returns a list of all permutations of a given list. For example, given the list [1;2;3], it should return
        [[1;2;3];[1;3;2];[2;1;3];[2;3;1];[3;1;2];[3;2;1]]
    
    The permutations may be in a different order.
  5. Define in F# the following functions on BinaryTree defined as follows:
         type BinaryTree = 
              | Void
              | Node of int*BinaryTree*BinaryTree
    
    A binary tree is either Void (empty tree) or Node(value,left,right), where value is the value stored in the node, left is the left subtree, and right is the right subtree.