User Tools

Site Tools


Sidebar

projects

  • dsi0 (due 20150128)
  • sln0 (due 20150204)
  • sln1 (due 20150211)
  • sll0 (due 20150225)
  • sll1 (due 20150304)
  • sll2 (due 20150311)
  • sll3 (due 20150408)
  • dll0 (due 20150408)
  • dll1 (due 20150415)
  • dls0 (due 20150422)
  • dlq0 (due 20150429)
  • dlt0 (due 20150506)
  • EoCE - see bottom of Opus (due 20150514 by 4:30pm)
haas:spring2015:data:projects:dll0

Corning Community College

CSCS2320 Data Structures

~~TOC~~

Project: DLL0

Errata

This section will document any updates applied to the project since original release:

  • revision 1: looks like I forgot to include the node unit tests, here they are (20150331)
    • there was a mild typo in the inc/node.h header file (FIXED)
      • the parameter to mknode() was incorrectly an int, it should be a char
    • updated unit-mklist to check for proper list return status codes
    • updated unit-display to check for proper list return status codes
  • revision 2: updated unit tests to support error condition status (20150402)
    • unit-display had a typo (FIXED)
    • unit-insert is now ready to go
    • unit-append should also be good to go
    • quieted compiler warnings for unit-cplist and unit-find (still need to finish)
  • revision 3: updated more unit tests to support error condition status (20150403)
    • unit-find is now operational and conformant to error condition status checking
    • there was a bug with checking for a DLL_SUCCESS result, this resulted in fixes to:
      • unit-display
      • unit-insert
      • unit-append
    • I've disabled the cplist unit test and verify-list does not try to run it (so you won't be impeded by its current unfinished state)
    • new options in base Makefile:
      • “reupdate”, which re-applies last revision
      • “reupdate-all”, which re-applies all revisions, from 1 to current
      • various backend infrastructure tweaks (because I deserve nice things)
  • revision 4: unit-cplist is now fully operational (20150404)
    • also did some house cleaning in list unit Makefile

Objective

In this project, we take our first opportunity to undergo a complete code re-write of linked list functionality, while we implement our first doubly linked list.

Procedure to Obtain dll0

As this is a rewrite, dll0 is not based on any of the code you have written up to this point. As such, the transition process is slightly different:

lab46:~/src/data/sll3$ make get-dll0
...

The “get-” functionality is distinct from the “upgrade-” you have been using to transition between the sll* projects. When you upgrade, your existing code is copied over, because the next project builds upon what you did previously.

But when you “get” dll0, you are getting an entirely new project skeleton- NONE of your existing code is copied over (the structure has changed enough where copying your own code would have been rather problematic).

Once you run “make get-dll0” you should have a dll0 directory that you can access and commence working on just as you have with the other project directories.

Project Overview

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:

In inc/node.h

1
#ifndef _NODE_H
#define _NODE_H
 
#include <stdlib.h>
 
struct node {
        char         value;
        struct node *after;
        struct node *prior;
};
typedef struct node Node;
 
Node *mknode(char  );     // allocate new node containing value
Node *cpnode(Node *);     // duplicate node
Node *rmnode(Node *);     // deallocate node
 
#endif

There is an addition of a “prior” node pointer, to allow connections to our previous neighbors.

The node info element has been renamed to “value”, just to make sure you understand what is going on code-wise.

In inc/list.h

1
#ifndef _LIST_H
#define _LIST_H
 
#include "node.h"                       // list relies on node to work
 
#define  DLL_SUCCESS            0
#define  DLL_MALLOC_FAIL        1
#define  DLL_ALREADY_ALLOC      2
#define  DLL_NULL               4
#define  DLL_EMPTY              8
#define  DLL_DEFAULT_FAIL       64
#define  DLL_FAIL               128
 
struct list {
    Node              *first;           // pointer to start of list
    Node              *last;            // pointer to end of list
};
typedef struct list    List;            // because we deserve nice things
 
int mklist (List **);                   // create/allocate new list struct
int cplist (List *,  List **);          // duplicate list contents 
 
int insert (List **, Node *, Node *);   // add node before given node
int append (List **, Node *, Node *);   // add node after given node
 
int display(List *,  int);              // display list from start to end
int find   (List *,  int,    Node **);  // locate node containing value
 
#endif

The following changes have taken place:

  • qty has been removed from the list
  • getpos()/setpos() are no longer present. In many ways their functionality is no longer needed with the doubly-linked nature of the list.
  • searchlist() has been renamed to find() (aesthetic change, to keep function names at 8 characters or less, and now supports resuming (finding additional matches).
  • displayf()/displayb() are gone, and previous functionality will be merged into one universal display() function.

There is now a set of status/error codes that will be utilized as list function return values, so we can better report particular failures.

list operation status codes

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.

  • 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_FAIL - some error occurred

For example, in the case of “DLL_MALLOC_FAIL”, there are actually a total of three states raised:

  • DLL_FAIL (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.

list library

In src/node/, you will find skeletons of what was previously there, ready for you to re-implement.

In src/list/, you will find the same- 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 testing/list/unit/, you will find these new files:

  • unit-mklist.c - unit test for mklist() library function
  • unit-cplist.c - unit test for cplist() library function
  • unit-append.c - unit test for append() library function
  • unit-insert.c - unit test for insert() library function
  • unit-find.c - unit test for find() library function
  • unit-display.c - unit test for display() library function

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:

  • 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!

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):

node library

Here is what you should get for node:

lab46:~/src/data/dll0$ bin/verify-node.sh 
====================================================
=    Verifying Doubly-Linked Node Functionality    =
====================================================
  [mknode] Total:   5, Matches:   5, Mismatches:   0
  [cpnode] Total:   6, Matches:   6, Mismatches:   0
  [rmnode] Total:   2, Matches:   2, Mismatches:   0
====================================================
 [RESULTS] Total:  13, Matches:  13, Mismatches:   0
====================================================
lab46:~/src/data/dll0$ 

list library

Here is what you should get for list:

lab46:~/src/data/dll0$ bin/verify-list.sh 
====================================================
=    Verifying Doubly-Linked List Functionality    =
====================================================
  [mklist] Total:  11, Matches:  11, Mismatches:   0
  [cplist] Total:  17, Matches:  17, Mismatches:   0
  [append] Total:  22, Matches:  22, Mismatches:   0
  [insert] Total:  22, Matches:  22, Mismatches:   0
 [display] Total:  12, Matches:  12, Mismatches:   0
    [find] Total:  28, Matches:  28, Mismatches:   0
====================================================
 [RESULTS] Total: 112, Matches: 112, Mismatches:   0
====================================================
lab46:~/src/data/dll0$ 

Submission Criteria

To be successful in this project, the following criteria must be met:

  • Project must be submit on time, by the posted deadline.
    • Late submissions will lose 25% credit per day, with the submission window closing on the 4th day following the deadline.
  • All code must compile cleanly (no warnings or errors)
    • all requested functions must be implemented in the related library
    • all requested functionality must conform to stated requirements (either on this project page or in comment banner in source code files themselves).
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output must be correct (i.e. the list visualization, where applicable) based on values input
  • Code must be nicely and consistently indented (you may use the indent tool)
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
    • Sufficient comments explaining the point of provided logic MUST be present
  • Track/version the source code in a repository
  • Submit a copy of your source code to me using the submit tool (make submit will do this) by the deadline.
haas/spring2015/data/projects/dll0.txt · Last modified: 2015/04/04 22:59 by wedge