Question: void rehash( ) { vector oldArray = array; // Create new double-sized, empty table array.resize( 2 * oldArray.size( ) ); for( auto & entry :

 void rehash( ) { vector oldArray = array; // Create new

void rehash( ) { vector oldArray = array;

// Create new double-sized, empty table array.resize( 2 * oldArray.size( ) ); for( auto & entry : array ) entry.info = EMPTY;

// Copy table over currentSize = 0; for( auto & entry : oldArray ) if( entry.info == ACTIVE ) insert( std::move( entry.element ) ); }

I grabbed some code from the Internet for my linear probing based hash table because the Internet's always right The hash table works but once I put more than a few thousand entries the whole thing starts to slow down Searches inserts, and contains calls start taking *way* longer than 0(1) time and my boss is pissed because it's slowing down the whole application services backend I'm in charge of. I think the bug's in my rehash code but I'm not sure where Any ideas why my hash table starts to suck as it grows bigger?/* * * Rehashing for linear probing hash table */void rehash() vector oldArray = array;//Create new double-sized empty table array re size(2 * ols array size ()) for (auto & entry: array) entry info = EMPTY;//Copy table Over current size for (auto & entry: oldArray) if(entry .info == ACTIVE) insert (std::move (entry element));}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!