![]() |
.. (לתיקייה המכילה) | |
ML Q3: The following DAGs will return 'false' even though the first one is "unique"... What can I do?
let
val d1 = Br(1,[])
in
val dag = Br(3,[d1,Br(2,[d1])])
end;
val dag2=Br(3,[Br(1,[]),Br(2,[Br(1,[])])]);
| You can assume the DAG is always a tree and you won't have this problem. |
ML General: From the answer above we understand there's no way to represent a DAG that is not a tree, unlike the examples in the assignment.
Can you explain this issue?
|
In all questions, except 'unique' we assume all nodes are different from each other. Thus, If a node has a value identical to another node, they both represent the same node in the graph. In 'unique' question (and only in that question), we assume the graph is always a tree. |
ML General: What it more important, time complexity or space complexity (tail recursion)?
|
You should first aim for a fast solution. Then, if possible, implement it in a 'tail-recursion' fashion. E.g. function 'f' of O(n^2) with O(1) space is worse than function 'f' of O(n) with O(n) space. |

