Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this project, you will implement a data abstraction called a hash map in C using the header file below. This version will map strings
For this project, you will implement a data abstraction called a hash map in C using the header file below. This version will map strings to arbitrary values. You will implement it as a utility that can be compiled with and used by any application. You will turn in your code in a file named strmap.cIf you can please implement the function strmapput, strmapget, and strmapremove
#include for printf, ONLY IN strmapdump
#include for strcmp
#include for malloccalloc
#define MAXBUCKETS
#define MINBUCKETS
typedef struct strmape
char smekey;
void smevalue;
struct strmape smenext;
smelt;
typedef struct sm
smelt strmapbuckets; array of pointers to elements
unsigned int strmapsize; # elements in the table
unsigned int strmapnbuckets; size of the array
strmapt;
Create a new hashtab, initialized to empty.
strmapt strmapcreateint numbuckets;
Insert an element with the given key and value.
Return the previous value associated with that key, or null if none.
void strmapputstrmapt m char key void value;
return the value associated with the given key, or null if none
void strmapgetstrmapt m char key;
remove the element with the given key and return its value.
Return null if the hashtab contains no element with the given key
void strmapremovestrmapt m char key;
return the # of elements in the hashtab
int strmapgetsizestrmapt m;
return the # of buckets in the hashtab
int strmapgetnbucketsstrmapt m;
print out the contents of each bucket
void strmapdumpstrmapt m;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started