Click here to Skip to main content
15,606,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone,

As I understand there are two kinds of binary trees:
1. Binary search trees (BST) and
2. Generic Binary trees

I am looking for implementing a generic binary tree in python. I am mainly looking at designing and implementing the insertion operation in the generic binary tree.

For Example :
# input is a list
L = [1,2,3,4,5,6,7,8,9]

# I expect the output to be a tree

           / \
          /   \
         2     3
        / \   / \
       /   |  |  \
      4    5  6   7
     / \
    /   \
   8     9

# I don`t want it to be printed in this manner, but I expect some data structure which stores the generic binary tree in this fashion. 

Thanks in advance !
CPallini 1-Jul-14 6:50am    
And what is your question?
joshrduncan2012 1-Jul-14 9:27am    
Do you want someone to write the code for you and hand you a ready-made solution?
Sergey Alexandrovich Kryukov 1-Jul-14 10:26am    
It is already designed. You only need to write your code, more or less mechanically. Where is your problem?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900