binary search trees using classes

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Sun Oct 28 01:36:27 EDT 2001


I have an implementation of a Red-Black Balanced Binary Tree at 

http://newcenturycomputers.net/projects/rbtree.html

Hope this helps.

----- Original Message ----- 
From: "christy johnson" <christy_girl99 at yahoo.com>


> Hi,
> I was wondering if anyone had a binary search tree
> module I could use? I need to write a program that
> counts the number of occurrences of each word in a
> file, and outputs the word and corresponding counts 
> alphabetically. For example, if input is
> 
> Have a nice day. Have a nice day. 
> Have a nice day.
> Have a nice day.
> 
> the output is
> 
> a 4
> day 4
> have 4
> nice 4
> 
> The code has to be modular based on classes. I'm
> thinking of making a
> tree node that looks like this  
> 
> bintree[ [key, data], left, right] ,  
> 
> where I can traverse the tree by simply incrementing
> the current root 
> to the appropriate child.
> 
> temp = bintree.root
> temp = temp[1]        #move to the left child.
> temp = temp[2]        #move to the right child.
> 
> but I don't know how to implement it correctly using
> classes. (i.e 
> using def __init__(self), etc)
> 
> I'm new to this python language so I would appreciate
> anyone's help.
> 
> Thanks in advance :)
> Christy
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 





More information about the Python-list mailing list