Questions tagged «tree-traversal»


5
jQuery查找与类最接近的先前同级
这是我可以使用的粗糙html: <li class="par_cat"></li> <li class="sub_cat"></li> <li class="sub_cat"></li> <li class="par_cat"></li> // this is the single element I need to select <li class="sub_cat"></li> <li class="sub_cat"></li> <li class="sub_cat current_sub"></li> // this is where I need to start searching <li class="par_cat"></li> <li class="sub_cat"></li> <li class="par_cat"></li> 我需要从遍历.current_sub,找到最接近的前一个.par_cat并对其进行处理。 .find("li.par_cat")返回的全部负载.par_cat(我在页面上大约有30个)。我需要瞄准一个。 非常感谢任何提示:)

8
在不使用堆栈或递归的情况下解释Morris有序树遍历
有人可以在不使用堆栈或递归的情况下帮助我了解以下Morris有序树遍历算法吗?我试图理解它是如何工作的,但是它只是在逃避我。 1. Initialize current as root 2. While current is not NULL If current does not have left child a. Print current’s data b. Go to the right, i.e., current = current->right Else a. In current's left subtree, make current the right child of the rightmost node b. Go to …


1
Python:超过最大递归深度
我有以下递归代码,在每个节点上我都调用sql查询来获取属于父节点的节点。 这是错误: Exception RuntimeError: 'maximum recursion depth exceeded' in <bound method DictCursor.__del__ of <MySQLdb.cursors.DictCursor object at 0x879768c>> ignored RuntimeError: maximum recursion depth exceeded while calling a Python object Exception AttributeError: "'DictCursor' object has no attribute 'connection'" in <bound method DictCursor.__del__ of <MySQLdb.cursors.DictCursor object at 0x879776c>> ignored 我调用以获得sql结果的方法: def returnCategoryQuery(query, variables={}): …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.