在C中反序列化BST

时间:2017-05-11 00:22:02

标签: c deserialization binary-search-tree

我正在尝试使用字符串构造BST。假设我的strlen总是处于2的幂状态,这样我就可以得到一个结构总是水平的结构,如下所示:

Tree

我无法启动此功能。我已经写了一个帮助器,它将构建一棵树到最后的点:

    In [38]: run("""ps aux | grep "[g]runt" """)
    [worker2] run: ps aux | grep "[g]runt" 

    Fatal error: run() received nonzero return code 1 while executing!

    Requested: ps aux | grep "[g]runt" 
    Executed: /bin/bash -l -c "ps aux | grep \"[g]runt\" "

    Aborting.
    An exception has occurred, use %tb to see the full traceback.

    SystemExit: run() received nonzero return code 1 while executing!

我想到达每个节点的末尾并在树的其余部分附加前两个字符等等。但我迷路了。

以下是结构:

tree* build(int height)
{
    int i;
    tree *t = malloc(sizeof(tree));
    t.tag = NODE;
    t.u = node;
    t.u.node->left = build(height - 1);
    t.u.node->right = build(height - 1);
    if(height == 1)
    {
        return t;
    }
}

0 个答案:

没有答案