Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include / / for printf, ONLY IN strmap _ dump #include / / for strcmp #include / / for malloc / calloc #define MAX _
#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