【问题标题】:OCaml Binary TreeOCaml 二叉树
【发布时间】:2017-03-11 04:57:22
【问题描述】:

通过这个Binary Tree传递下面的函数:

let rec inorder(t:tree) : int list =
  begin match t with
    | Empty -> []
    | Node (left, x, right) -> inorder left @ (x :: inorder right)
   end 

为什么结果是 [1;2;3;4;5;6;7] 而不是 [1;2;3;4;5;7;6]?

【问题讨论】:

    标签: tree ocaml binary-tree traversal inorder


    【解决方案1】:

    嗯,在您链接到的树形图中,7 确实在 6 之前。

    传递给inorder 函数的实际数据是什么样的?

    【讨论】:

    • 这棵树实际上是在一个问题集中给出的——也许答案键是错误的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多