Download presentation
Presentation is loading. Please wait.
1
Programming Assignment 2A
CMSC 331 Fall 2009 Due Thurs 11/19/09
2
Code the following [10 pts] Using the IntTree case class discussed during lecture write a method that sums the values in the nodes of the IntTree [15 pts] Write the following traversal methods (i.e of type Intree-> List[Int]) Inorder Preorder Postorder [10 pts] Write a method that is like 2a except that it supports filtering. The method takes an additional argument that is a function of type Int->Boolean, if the function returns true when applied to a node then the the value at the node is filtered out of the resultant inorder list. [5 pts] Generalize an IntTree so that the nodes can contain a value of any type T (all you need is the definition here) [10 pts] Write a method that allows you to apply a function of type T->S to the new class created in (4) to create a tree of S’s.
3
Submission Instructions
Put the answers to the questions in a script file Mail that script file to me at with the subject line CMSC_331_P2A_FA_09
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.