User Tools

Site Tools


Sidebar

projects

  • dsi0 (due 20150607)
  • sln0 (due 20150607)
  • sln1 (due 20150607)
  • sll0 (due 20150607)
  • sll1 (due 20150614)
  • sll2 (due 20150614)
  • sll3 (due 20150621)
  • sll4 (due 20150621)
  • dln0 (due 20150628)
  • dll0 (due 20150628)
haas:summer2015: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 #: <description> (DATESTAMP)

Objective

In this project, we continue our doubly-linked code re-write, this time focusing on the linked list.

Procedure to obtain dll0

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.

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/list.h

1
#ifndef _LIST_H
#define _LIST_H
 
#include "node.h"                          // list relies on node to work
 
struct list {
    Node              *first;              // pointer to start of list
    Node              *last;               // 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  *, int,    Node **); // locate node with value
 
#endif

The following changes have taken place from the singly-linked list implementation:

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

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 inc/data.h

In addition to what was there previously, we see the following:

1
// Status codes for the doubly linked list implementation
//
#define  DLL_SUCCESS         0x0000000000000100
#define  DLL_MALLOC_FAIL     0x0000000000000200
#define  DLL_ALREADY_ALLOC   0x0000000000000400
#define  DLL_NULL            0x0000000000000800
#define  DLL_ERROR           0x0000000000001000
#define  DLL_DEFAULT_FAIL    0x0000000000002000
#define  DLL_EMPTY           0x0000000000004000
#define  DLL_INVALID         0x0000000000008000

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 (so, the list as a result of the function processing leaves us with an empty list).

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_ERROR - some error occurred
  • DLL_INVALID - invalid use (passing a NULL pointer)

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.

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 unit/list/, 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):

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

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/summer2015/data/projects/dll0.txt · Last modified: 2015/06/27 20:30 by wedge