Corning Community College CSCS2320 Data Structures ======Project: DLL1====== =====Errata===== This section will document any updates applied to the project since original release: * __revision #__: (DATESTRING) =====Objective===== In this project, we continue our doubly linked list re-write, completing the remaining library functions. =====Procedure to Obtain dll1===== As this project utilizes the code you wrote in dll0, you must upgrade to dll1 from dll0 (same thing that we did to transition between the sll* projects): lab46:~/src/data/dll0$ make upgrade-dll1 ... =====Project Overview===== As we started with the last project, we're implementing the remaining functions of our new doubly linked list implementation. As such, new function prototypes have been added to the list.h header file: code_t obtain (List **, Node **); // disconnect node from list code_t empty (List **); // empty an existing list code_t rmlist (List **); // deallocate empty list code_t compare (List *, List *, ulli *); // compare two lists code_t sortlist(List **, int); // sort list by mode code_t swapnode(List **, Node *, Node *); // swap nodes in list These functions will also make use of the status/error codes introduced in dll0. Additional effort has gone into identifying likely codes applied in various conditions. Be sure to reference the provided comments as well as the unit tests for more information. The recommended order of implementation is: - **obtain()** - **empty()** - **rmlist()** - **compare()** - **swapnode()** - **sortlist()** (although note that sorting doesn't necessarily need swapping) Implementing them out of order will likely result in unnecessary duplication of efforts, and I really don't want to see a half dozen half-baked **obtain()** implementations dribbled throughout your code. ====list operation status codes==== Just as with dll0, you'll notice the presence of a set of #define's in the **data.h** file. These are intended to be used to report on various states of list status after performing various operations. They are not exclusive- in some cases, multiple states can be applied. The intent is that you will OR together all pertinent states and return that from the function. * **DLL_SUCCESS** - everything went according to plan, no errors encountered, average case * **DLL_MALLOC_FAIL** - memory allocation failed (considered in error) * **DLL_ALREADY_ALLOC** - memory has already been allocated (considered in error) * **DLL_NULL** - result is NULL (probably in error) * **DLL_EMPTY** - result is an empty list (may or may not be in error) * **DLL_DEFAULT_FAIL** - default state of unimplemented functions (default error) * **DLL_ERROR** - some error occurred * **DLL_INVALID** - invalid list condition For example, in the case of "DLL_MALLOC_FAIL", there are actually a total of three states raised: * DLL_ERROR (a problem has occurred) * DLL_MALLOC_FAIL (a problem has occurred when using malloc()) * DLL_NULL (no memory allocated, so list cannot be anything but NULL) ALL THREE states must be returned from the function in question should such an occurrence take place. ===compare status codes=== dll1 introduces additional status codes for one of its functions: **compare()** Those codes are as follows: ////////////////////////////////////////////////////////////////////// // // Status codes for the doubly-linked list compare() function // #define CMP_EQUALITY 0x00 #define CMP_L1_NULL 0x01 #define CMP_L1_EMPTY 0x02 #define CMP_L1_UNDEFINED 0x03 #define CMP_L1_GREATER 0x04 #define CMP_L1_LESS 0x08 #define CMP_L2_NULL 0x10 #define CMP_L2_EMPTY 0x20 #define CMP_L2_UNDEFINED 0x30 #define CMP_L2_GREATER 0x40 #define CMP_L2_LESS 0x80 ====list library==== In **src/list/**, you will find the addition of a new set of skeletons of the above prototyped functions, hollowed out in anticipation of being made operational. Figure out what is going on, the connections, and make sure you understand it. Be sure to focus on implementing the functionality from scratch (the more you do this from scratch, vs. referencing old code, the more it will help you). ====List library unit tests==== In **unit/list/**, you will find these new files: * **unit-obtain.c** - unit test for **obtain()** library function * **unit-empty.c** - unit test for **empty()** library function * **unit-rmlist.c** - unit test for **rmlist()** library function * **unit-compare.c** - unit test for **compare()** library function * **unit-swap.c** - unit test for **swapnode()** library function * **unit-sort.c** - unit test for **sortlist()** library function Enhancements to these unit tests may be provided via dll1 project updates. There are also corresponding **verify-FUNCTION.sh** scripts that will output a "MATCH"/"MISMATCH" to confirm overall conformance with the pertinent list functionality. These are complete runnable programs (when compiled, and linked against the list library, which is all handled for you by the **Makefile** system in place). Of particular importance, I want you to take a close look at: * the source code to each of these unit tests * the purpose of these programs is to validate the correct functionality of the respective library functions * follow the logic * make sure you understand what is going on * ask questions to get clarification! * the output from these programs once compiled and ran * analyze the output * make sure you understand what is going on * ask questions to get clarification! Also note that, while considerable effort was made to ensure a broad range of tests were incorporated into each unit test, they are by no means a complete nor exhaustive battery of tests. There may be scenarios the unit tests do not currently check for. You are welcome and encouraged to perform additional tests to ensure your implementation is as rock solid as it can be. ====List library applications==== ===palindrome=== Now that we've completed our doubly-linked list functionality, we can use these individual functions to piece together solutions to various everyday problems where a list could be effective. After all, that's a big aspect to learning data structures- they open doors to new algorithms and problem solving capabilities. Our endeavor here will be to revisit that of palindromes (ie words/phrases that, when reversed, spell the same thing). This implementation will be considered an extra credit opportunity, so as to offer those who have fallen behind (but working to get caught up) a reprieve on some of the credit they've lost. It is also highly recommended to undertake as it will give you further experience working with these concepts. =====Expected Results===== To assist you in verifying a correct implementation, a fully working implementation of the node and list libraries should resemble the following (when running the respective verify script): ====list library==== Here is what you should get for list: lab46:~/src/data/dll1$ make check ====================================================== = Verifying Doubly-Linked List Functionality = ====================================================== [obtain] Total: 57, Matches: 57, Mismatches: 0 [empty] Total: 7, Matches: 7, Mismatches: 0 [rmlist] Total: 7, Matches: 7, Mismatches: 0 [compare] Total: 12, Matches: 12, Mismatches: 0 [swapnode] Total: 31, Matches: 31, Mismatches: 0 [sortlist] Total: 48, Matches: 48, Mismatches: 0 ====================================================== [RESULTS] Total: 162, Matches: 162, Mismatches: 0 ====================================================== lab46:~/src/data/dll1$ =====Submission===== {{page>haas:fall2017:common:submitblurb#DATA&noheader&nofooter}}