and the only allowed constants are 1 2 4 8 16 Using invalid operators or

# And the only allowed constants are 1 2 4 8 16 using

• Test Prep
• 7
• 100% (2) 2 out of 2 people found this document helpful

This preview shows page 6 - 7 out of 7 pages.

Using invalid operators or constants will result in losing significant credit. unsigned int times10(unsigned int x) { Problem #3 (30 pts) The function get_prefix(whose prototype is at the end) returns 1 if the srcstring ends with the string endingand 0 otherwise. When the function returns 1, the prefixstring will be initialized with the prefix of the string. For example, the statement printf("%d %s\n", get_prefix("talking", "ing", prefix), prefix);prints: 1 talk. For this problem: You may only use the strcmp, strlen, and strcpy string functions. You can assume the srcand endingparameters will always be different and will have a minimum length of 1. The prefixparameter represents a string large enough to fit the result. Hint:You can solve this problem by first copying the srcstring to prefix, and then comparing substrings of prefixagainst ending src .
7 Problem #4 (50 pts) Complete the implementation of the hash table deletefunction below. The function will reduce the number of instances for the specified key by 1, and remove (as you did in your project) the keyonly when the number of instances reaches 0. You can assume that when this function is called, the keystring is in the hash table. The structures below are exactly the same ones used in your project (except that an integer (instances) is used rather than a string). typedef enum { EMPTY, FULL, DELETED } Bucket_state; typedef struct { char key[MAX_STR_SIZE + 1]; int instances; /* Replaces char value[MAX_STR_SIZE + 1];*/} Data_pair; typedef struct { Bucket_state state; Data_pair data; } Hash_bucket; struct hash_table { int key_ct; Hash_bucket buckets[NUM_BUCKETS]; }; typedef struct hash_table Table;