need help on a data structure problem

Tom Plunket tomas at fancy.org
Thu Feb 1 22:55:55 EST 2007


Dongsheng Ruan wrote:

> Not quite related with Python. But my Data Structure course is experiemented 
> on python and there is no data structure group, So I have to post here:
> 
> Write a procedure (in pseudocode!) to increase the number of buckets in a 
> (closed) hash table. Analyze its time and space complexity. 

What is the question about this problem that you would like to have
answered?  Certainly you don't want us to actually give you the answers
to your homework?!?

Here's some Python code to get us started with the discussion:

class HashTable:
   def __init__(self):
      self.buckets = [ [] ]

   @staticmethod
   def Hash(object):
      return 0

   def InsertItem(self, item):
      self.buckets[Hash(item)].append(item)

The more I think about it, the more I realize you could probably just
cut'n'paste that code and that should suffice for your answer!  Good
luck in Computer Science!


-tom!

-- 



More information about the Python-list mailing list