How to create a complete binary tree of height 'h' using Python?
Posted
by Jack
on Stack Overflow
See other posts from Stack Overflow
or by Jack
Published on 2010-04-08T11:49:38Z
Indexed on
2010/04/08
11:53 UTC
Read the original article
Hit count: 285
python
|binary-trees
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.
© Stack Overflow or respective owner