标签: tree-traversal

Jquery prev()不能使用输入

我不能用prev改变css,我的错误在哪里?Fiddlelink

坦克寻找!


CSS:

.i1 {
    float: right;
    height: 18px;
    margin-top: 6px;
}
label {
    border-bottom: 1px dotted #CCCCCC;
    clear: both;
    float: left;
    height: 25px;
    margin: 5px 0 0;
    width: 450px;
    line-height: 32px;
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<label>Titel:<input class="i1" type="text" name="titel" value="" /></label>
<label>Vorname:<input class="i1" type="text" name="vorname" value="" /></label>
<label>Nachname:<input class="i1" type="text" name="nachname" value="" /></label>
Run Code Online (Sandbox Code Playgroud)

jQuery的:

  $("input").focus(function () {
    $(this).prev("label").css("border-bottom", "1px dotted #63aec4");
  });
Run Code Online (Sandbox Code Playgroud)

jquery tree-traversal

0
推荐指数
1
解决办法
232
查看次数

迭代螺纹二叉树遍历只有恒定的额外空间

如何在不使用堆栈的情况下非递归地遍历O(n)中线程二叉树(只允许为临时变量使用常量额外空间,因此我们不能将访问标志添加到树中的每个节点).我花了很多时间思考它,但除非我们要遍历具有树数据的内存位置,否则我似乎并不可行.假设我们使用多个数组表示来实现指针,然后我们可以遍历O(n)中的树,是否有人有其他想法?

注意不是功课,只是为了节省一些键盘敲击的能量来写关于作业的评论!

binary-tree tree-traversal non-recursive data-structures

0
推荐指数
1
解决办法
2788
查看次数

在Python 3.x中写入文件

from arrayheap import ArrayHeap
    def generateTable(self, node, table):
        def codeTable(node, codeString):
            if node.isLeaf:
                table[node._char] = codeString
                return
            if node.getleft() is not None:
                table(node.getLeft(), codeString + '0')
            if node.getRight() is not None:
                table(node.getRight(), codeString + '1')
        codeTable(node, '')
        return(table)

def main():
    with open('codetable.txt', 'w') as cdt:
        codeTable = {}
        codeTable = HTree.generateTable(HTree, codeTable)
        for i in sorted(codeTable):
            cdt.write(str(i) + '\t' + str(codeTable[i]) + '\n')
main()
Run Code Online (Sandbox Code Playgroud)

我试图输出到文件的二进制遍历树中的每个单独节点.我已将预订和后序遍历方法留在文件中以供参考.我的问题是我的generateTable()方法出了什么问题(大部分代码都是提供给我的)我想输出它,以便它以格式列出遍历,0左边1是正确的<ascii value> : <binary path>.问题是,当我运行此代码时,我的输出文件codetable.txt为空.我究竟做错了什么?

python file-io tree-traversal python-3.x

0
推荐指数
1
解决办法
104
查看次数

如何按字母顺序列出三元搜索树的单词?

如何才能按字母顺序列出TST包含的单词?

与按顺序遍历可以解决问题的BST不同,TST不起作用。前遍历和后遍历都不会。

更重要的是,与某些BST实现的节点相反,TST的节点包含字母而不是单词。从左节点移动到右节点时,有些字母不包括在内。

我似乎可以绕开它。

下图按字母顺序显示了TST的单词列表。

尖沙咀

图片来自:http : //www.geeksforgeeks.org/ternary-search-tree/

algorithm tree tree-traversal data-structures ternary-search-tree

0
推荐指数
1
解决办法
1997
查看次数

如何仅使用 iostream 库打印二叉搜索树中的所有节点?

我想打印树中的所有节点(首先打印低级别的节点,对于具有相同输出级别的节点,首先打印具有较小值的节点)例如:输入 在此处输入图片说明

预期输出:10 6 20 1 8 18 21 7 25。 我试着这样编码

void print_Nodes(Node *root)
{
    if(root == nullptr) return;
        cout << root->value << " ";
    if(root->left!=nullptr){
        cout << root->left->value << " ";
        if(root->right!=nullptr){
            cout << root->right->value << " ";
        }
    }
    print_Nodes(root->right);
    print_Nodes(root->left);
}
Run Code Online (Sandbox Code Playgroud)

但输出是:10 6 20 6 1 8 1 8 7 7 20 18 21 18 21 25。 你能指导我如何解决这个问题吗?

c++ tree binary-tree tree-traversal

0
推荐指数
1
解决办法
378
查看次数

如何创建一个返回无序二叉树最小值的函数

这似乎应该很容易,但我已经有很长一段时间没遇到这个问题了.正如标题所说,我只是试图找到具有最小值的二叉树(不是BST!)中的节点并返回它.我可以很容易地写一个递归的void函数,至少可以在函数中分配最小的值,但是当我到达NULL指针时,我会陷入如何回溯到先前节点的问题.

我有一个节点类,它有一个指向左右子节点的指针,每个子节点都有自己的值.到目前为止,这是我的(失败)尝试:

int preOrder(Node *node, int value, int count, int sizeOfTree)
{
  count++; //keeps track of whether or not we have traversed the whole tree

  if(value < node->getValue())
    value = node->getValue(); 

  if(count == sizeOfTree);
    return value;

  if(node == NULL)
    //Want to return to the previous function call
    //How do I do this for a non void function? 
    //for a void function, you could jsut type "return;" and the function
    //back tracks to your previous place in the tree
    //but since …
Run Code Online (Sandbox Code Playgroud)

c++ tree binary-tree tree-traversal

-1
推荐指数
1
解决办法
3673
查看次数