binary search trees using classes

Michael R. Head burner at core.binghamton.edu
Sun Oct 28 07:34:21 CET 2001


A quick google search ( "binary search" site:python.org ) turns up
this reference (among many others):

http://mail.python.org/pipermail/python-list/2001-February/030678.html

mike

> From: christy johnson <christy_girl99 at yahoo.com>
> Subject: binary search trees using classes
> 
> 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
> 
> 
> 


Content-Description: Digest Footer
> -- 
> http://mail.python.org/mailman/listinfo/python-list


-- 
Michael R. Head
burner at core.binghamton.edu
GPG public key: http://www.core.binghamton.edu/~burner/gpg.key.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 536 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20011028/b6a464e8/attachment.pgp>


More information about the Python-list mailing list