Start New Discussion within our Software Development Community

can some one help me to develop the code for the following methods

private void add(Bucket bucket)
{ // is the bucket in the table?
  // can it be added to the table?
  // can the bucket be added at its hashed index?
  // what is to be done if the hashed index bucket != null?
  // can the bucket be added at a rehashed wrap-around index?
  // what is to be done if the rehashed index bucket != null?
  // are other keys required to be moved by the insertion sort addition?
  // when adding the bucket, what private members are to be updated?
}
public void remove(int key)
{ // is the key valid?
  // is the key in a bucket in the table?
  // is the key at its hashed index?
  // is the key at a rehashed index?
  // are other keys required to be moved by the insertion sort removal?
  // when removing the key’s bucket, what private members are to be updated?
}

is the below code correct

private void Add(Bucket bucket)

             Add(right);
 
             foreach (Node n in bucket.Nodes)
           Add(n);
                Add(n, false);
 
             if (bucket.Replacement != null)
               Add(bucket.Replacement);
                Add(bucket.Replacement, false);
 
             return true;
         }

// is the bucket in the table?

I don't know, is the table round?

// can it be added to the table?

Perhaps.

// can the bucket be added at its hashed index?

If there's nothing else there, why not?

// what is to be done if the hashed index bucket != null?

Put the bucket there.

// can the bucket be added at a rehashed wrap-around index?

I forget, didn't pay all that much attention in Data Structs. But now that you're in it, I'd say answer this yourself.

// what is to be done if the rehashed index bucket != null?

See above!


:)

This article has been dead for over six months. Start a new discussion instead.