Question: C++ Using a DynamicArray and Doubly-Linked list, create a Hashtable. The Hashtable is a DynamicArray of doubly LinkedLists. The LinkedLists handle the collisions. Read the

C++ Using a DynamicArray and Doubly-Linked list, create a Hashtable. The Hashtable is a DynamicArray of doubly LinkedLists. The LinkedLists handle the collisions. Read the customers.txt and store it in a ADT. Let the user search for a customer, then print that customer's information.

class Customer string lastname string firstname string id customers.txt (in the format of last,first,id), is as follows. The file can be longer. perez,diana,86824983-3587182 oxford,greg,49451687-6884854 smith,tsung,34722447-9802850

Place each ADT data object into the Hashtable structure using a custom Hashing function. Recommend coding a Hashing Function based on the Customer-id.

//DynamicArray class:

template

class DynamicArray

{

T* base;

int size = 0;

int capacity = 0;

public:

DynamicArray(int c = 10) : capacity(c) { allocate(capacity); }

void set(T v, int offset)

{

if (offset >= capacity)

resize(capacity*2);

base[offset] = v;

size++;

}

T get(int offset) { return base[offset]; }

int length() { return size; }

int extent() { return capacity; }

T begin() { return base[0]; }

T end() { return base[size - 1]; }

void push(T t) { set(t, size); }

void allocate(int c)

{

capacity = c;

base = new T[capacity];

}

void resize(int nusize)

{

T* temp = new T[nusize];

for (int i = 0; i < capacity; i++)

temp[i] = base[i];

delete[] base;

base = temp;

capacity = nusize;

}

void pop()

{

for (int i = 1; i < size; i++)

base[i - 1] = base[i];

size--;

}

void clear()

{

delete[] base;

size = 0;

capacity = 0;

}

T& operator[](int index) { return base[index]; }

};

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!