projects
projects
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 code re-write, this time focusing on the linked list.
As dll0 utilizes the code generated in dln0, transitioning to this project is merely a matter of upgrading:
lab46:~/src/data/dln0$ make upgrade-dll0 ...
When you upgrade, your existing code is copied over, because the next project builds upon what you did previously.
Once you run “make upgrade-dll0” you should have a dll0 directory that you can access and commence working on just as you have with the other project directories.
For this project, we're going to be re-implementing MOST of the previous node and list functions. There have been a few changes, namely:
#ifndef _LIST_H #define _LIST_H #include "node.h" // list relies on node to work struct list { Node *initial; // pointer to start of list Node *closing; // pointer to end of list }; code_t mklist (List **); // create new list struct code_t cplist (List *, List **); // duplicate list contents code_t insert (List **, Node *, Node *); // add node before given node code_t append (List **, Node *, Node *); // add node after given node code_t display(List *, int); // display list start to end code_t find (List *, char, Node **); // locate node with value #endif
The following changes have taken place from the singly-linked list implementation:
Just as with the doubly-linked node, there are now a set of status/error codes that will be utilized as list function return values, so we can better report particular failures.
In addition to what was there previously, we see the following:
////////////////////////////////////////////////////////////////////// // // Status codes for the doubly linked list implementation // #define DLL_SUCCESS 0x0000000000010000 #define DLL_MALLOC_FAIL 0x0000000000020000 #define DLL_ALREADY_ALLOC 0x0000000000040000 #define DLL_NULL 0x0000000000080000 #define DLL_ERROR 0x0000000000100000 #define DLL_EMPTY 0x0000000000200000 #define DLL_INVALID 0x0000000000400000 #define DLL_DEFAULT_FAIL 0x0000000000800000 ////////////////////////////////////////////////////////////////////// // // Options for list display() and support catlist() functions // #define DISPLAY_FORWARD 000 #define DISPLAY_NOPOSVALS 000 #define DISPLAY_POSVALS 001 #define DISPLAY_BACKWARD 002
Similar in many ways to the doubly-linked node status codes, we see a new possibility: EMPTY. This is the state of a list existing but having no nodes associated with it (which you should already be familiar with). Whenever this state exists, that status code MUST be set in the respective function being called (i.e. the list as a result of the function processing leaves us with an empty list).
You'll notice the presence of a set of #define's in the list header 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.
In src/list/, you will find 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 dll0 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:
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/dll0$ bin/verify-list.sh ====================================================== = Verifying Doubly-Linked List Functionality = ====================================================== [mklist] Total: 12, Matches: 12, Mismatches: 0 [cplist] Total: 18, Matches: 18, Mismatches: 0 [append] Total: 36, Matches: 36, Mismatches: 0 [insert] Total: 36, Matches: 36, Mismatches: 0 [display] Total: 12, Matches: 12, Mismatches: 0 [find] Total: 28, Matches: 28, Mismatches: 0 ====================================================== [RESULTS] Total: 142, Matches: 142, Mismatches: 0 ====================================================== lab46:~/src/data/dll0$
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: