projects
- php0 (due 20150909)
Corning Community College
CSCS2320 Data Structures
~~TOC~~
This section will document any updates applied to the project since original release:
In this project, we continue our doubly linked list re-write, completing the remaining library functions.
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 ...
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:
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.
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.
For example, in the case of “DLL_MALLOC_FAIL”, there are actually a total of three states raised:
ALL THREE states must be returned from the function in question should such an occurrence take place.
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_GREATER 0x04 #define CMP_L1_LESS 0x08 #define CMP_L2_NULL 0x10 #define CMP_L2_EMPTY 0x20 #define CMP_L2_GREATER 0x40 #define CMP_L2_LESS 0x80
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).
In unit/list/, you will find these new files:
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:
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.
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.
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):
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$
When you are done with the project and are ready to submit it, you simply run make submit:
lab46:~/src/data/PROJECT$ make submit ...
To be successful in this project, the following criteria must be met: