tree-traversal

Python: Maximum recursion depth exceeded

Python: Maximum recursion depth exceeded Question: I have the following recursion code, at each node I call sql query to get the nodes belong to the parent node. here is the error: 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 …

Total answers: 1

Help me understand Inorder Traversal without using recursion

Help me understand Inorder Traversal without using recursion Question: I am able to understand preorder traversal without using recursion, but I’m having a hard time with inorder traversal. I just don’t seem to get it, perhaps, because I haven’t understood the inner working of recursion. This is what I’ve tried so far: def traverseInorder(node): lifo …

Total answers: 15

Printing BFS (Binary Tree) in Level Order with Specific Formatting

Printing BFS (Binary Tree) in Level Order with Specific Formatting Question: To begin with, this question is not a dup of this one, but builds on it. Taking the tree in that question as an example, 1 / 2 3 / / 4 5 6 How would you modify your program to print it so, …

Total answers: 16