- 作业标题:CSCI 3137 - Assignment 6: Parameter Passing and Tree Traversals
- 课程名称:Dalhouse University CSCI 3137 Principles of Programming Languages
- 完成周期:2天
Question 1: Pass by Reference in Java (4 points)
In Wednesday’s class, we discuss parameter passing modes. Assume foo calls bar with some local variable x of foo as argument. When passing x to bar by reference, this means that bar receives a pointer to x’s location in foo’s stack frame. In particular, bar can make arbitrary modifications to the content of foo’s variable x. C only has pass by value, but it has explicit pointers. Thus, we can easily simulate pass by reference using code like this:
。。。
Question 2: Tree Traversals in Haskell (4 points + 2 bonus points)
Haskell data structures, take 2 (after last week’s Haskell question ended up being too ambitious). Here’s an implementation of a rooted tree storing some elements of type a:
Bonus: Level-order numbering and laziness
。。。
Submission
Assignments are due by 11:59 PM on the due date. Assignments must be submitted electronically via Brightspace. Only a single PDF is accepted. You can do your work on paper and then scan it and submit the scanned. If at all possible, scan your assignment instead of taking a photo. The result will be more readable. If you do need to take a photo, ensure proper lighting and that the camera is properly focused. If the marker cannot read your work, you don’t earn any marks. Even if you take a photo or photos, it is your responsibility to convert the photos to a single PDF with the pages in the correct order.