Drawing a diagram of the data structures will help you


1 - Implement and test dictionary_build

This first function, which you will implement in tools.c, will be used every time you need to start working on a new dictionary. Part of your grade on this implementation will be on how well your function handles error situations; e.g. we ask for a dictionary of negative size, there is no memory available for your malloc...

Any time you encounter one of these, or similar, errors, you should return a specific value from your function which is described in the program's source itself. When you test your function with such parameters, you should verify its return value is appropriate.

Make sure you follow our usual process when working on this function;

- Read the requirements & existing source thoroughly

- Implement your tests based on how you understand the requirements. This time you will note that we are not providing tests at all. Part of your work is to leverage what you learned in the previous PAs to design & implement your own tests

- Implement the function dictionary_build

- Update your tests based on what you learned

- Refactor your solution before to go to the next task.

2 - Implement and test dictionary_free

This 2nd function will be used to de-allocate a dictionary. Here are some things to keep in mind;

- Make sure you dispose of all the memory you allocated in a struct dictionary.

Drawing a diagram of the data structures will help you figure out what you are deallocating as you write your dictionary_free function. This should help you avoid memory leaks.

- If the dictionary passed to your function is only partially allocated - e.g. due to a bug elsewhere - you should handle it gracefully; i.e. before to free a pointer, make sure it is not NULL.

Follow the steps outlined in task#1 as you work on implementing this task. Again, the source code provides you with most of the information you need in the form of comments and the code itself.

3 - Implement and test dictionary_add

The 3rd function will take a dictionary and two strings as parameters. It will use strdup to make a copy of the words provided as parameters and insert them as a new element in the dictionary.

Again, detect possible bad parameters; e.g. no words provided; 1 word instead of 2... and verify the return value is appropriate based on the documentation in the program itself.

Follow the steps outlined in task#1 as you work on implementing this task.

4 - Implement and test dictionary_translate

This function, as indicated in its comments, will return a strdup copy of the translation of one of the two strings passed as parameter. It is expected that one will use this function with a valid dictionary, and specify one of the two strings to be NULL.

- If the English word parameter is NULL, we are providing a string in the foreign language to be translated into English.
- If the foreign word is NULL, we do the opposite.

Passing two non-NULL strings or a NULL dictionary are errors which should be handled by your function returning the value described in the documentation in the program itself.

Follow the steps outlined in task#1 as you work on implementing this task.

Request for Solution File

Ask an Expert for Answer!!
Database Management System: Drawing a diagram of the data structures will help you
Reference No:- TGS01066015

Expected delivery within 24 Hours