larsmans answered your first question
For your second question, can you simply look before you leap to avoid recursion?
def makeList(self, aNode=None):
if aNode is None:
aNode = self.root
treeaslist = [aNode.data]
if aNode.lChild:
treeaslist.extend(self.makeList(aNode.lChild))
if aNode.rChild:
treeaslist.extend(self.makeList(aNode.rChild))
return treeaslist
Related Contents:
- Hitting Maximum Recursion Depth Using Pickle / cPickle
- Why does my recursive function return None?
- How to access object attribute given string corresponding to name of that attribute
- Recursive function returning none in Python [duplicate]
- How do I call a parent class’s method from a child class in Python?
- Nested defaultdict of defaultdict
- Find all occurrences of a key in nested dictionaries and lists
- Saving and loading multiple objects in pickle file?
- Basics of recursion in Python
- Is everything an object in Python like Ruby?
- How to do a recursive sub-folder search and return files in a list?
- How can I create a copy of an object in Python?
- id()s of bound and unbound method objects — sometimes the same for different objects, sometimes different for the same object
- Finding a key recursively in a dictionary
- Referring to the null object in Python
- How can I build a recursive function in python? [duplicate]
- Can a lambda function call itself recursively in Python?
- Accessing Object Memory Address
- Function with varying number of For Loops (python)
- Is there a module for balanced binary tree in Python’s standard library?
- Is there a recursive version of the dict.get() built-in?
- How do I save and restore multiple variables in python?
- How to convert a nested Python dict to object?
- How to recursively find specific key in nested JSON?
- Python: simple list merging based on intersections
- How can I separate the functions of a class into multiple files?
- Null object in Python
- How can I create an object and add attributes to it?
- Why doesn’t assigning to the loop variable modify the original list? How can I assign back to the list in a loop? [duplicate]
- Python recursion permutations
- Difference between ‘cls’ and ‘self’ in Python classes?
- Why do I get a TypeError that says “takes no arguments (1 given)”? [duplicate]
- How can you get the call tree with Python profilers?
- What is the hard recursion limit for Linux, Mac and Windows?
- Process finished with exit code -1073741571
- How to access (get or set) object attribute given string corresponding to name of that attribute
- How do I correctly setup and teardown for my pytest class with tests?
- Confusing […] List in Python: What is it?
- Given a list of elements in lexicographical order (i.e. [‘a’, ‘b’, ‘c’, ‘d’]), find the nth permutation – Average time to solve?
- Recursion using yield
- Evaluation of boolean expressions in Python
- Deleting node in BST Python
- Dictionary vs Object – which is more efficient and why?
- Python: using a recursive algorithm as a generator
- python recursive function that prints from 0 to n?
- Counting recursive calls of a function
- What happens when you assign the value of one variable to another variable in Python?
- Creating nested dataclass objects in Python
- What is the maximum recursion depth, and how to increase it?
- How do I check if an object has an attribute?