How to create a complete binary tree of height 'h' using Python?
- by Jack
Here is the node structure
class Node:
def __init__(self, data):
# initializes the data members
self.left = None
self.right = None
self.parent = None
self.data = data
complete binary tree
Definition: A binary tree in which every level, except possibly the deepest, is completely filled. At depth n, the height of the tree, all nodes must be as far left as possible.
-- http://www.itl.nist.gov/div897/sqg/dads/HTML/completeBinaryTree.html
I am looking for an efficient algorithm.