User Tools

Site Tools


Sidebar

projects

haas:spring2016:hpc0: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  *, char,   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         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).

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/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).

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

Project Submission

When you are done with the project and are ready to submit it, you simply run make submit:

lab46:~/src/data/PROJECT$ make submit
...

Submission Criteria

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

  • Project must be submit on time, by the posted deadline.
    • Early submissions will earn 1 bonus point per full day in advance of the deadline.
      • Bonus eligibility requires an honest attempt at performing the project (no blank efforts accepted)
    • Late submissions will lose 25% credit per day, with the submission window closing on the 4th day following the deadline.
      • To clarify: if a project is due on Wednesday (before its end), it would then be 25% off on Thursday, 50% off on Friday, 75% off on Saturday, and worth 0% once it becomes Sunday.
      • Certain projects may not have a late grace period, and the due date is the absolute end of things.
  • 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).
  • Output generated must conform to any provided requirements and specifications (be it in writing or sample output)
    • output obviously must also be correct based on input.
  • Processing must be correct based on input given and output requested
  • Code must be nicely and consistently indented (you may use the indent tool)
    • You are free to use your own coding style, but you must be consistent
    • Avoid unnecessary blank lines (some are good for readability, but do not go overboard- double-spacing your code will get points deducted).
    • Indentation will be rated on the following scale (worth 3 total points):
      • 3/3: Aesthetically pleasing, pristine indentation, easy to read, organized
      • 2/3: Mostly consistent indentation, but some distractions (superfluous or lacking blank lines, or some sort of “busy” ness to the code)
      • 1/3: Some indentation issues, difficult to read
      • 0/3: Lack of consistent indentation (didn't appear to try)
  • Unless fundamentally required, none of your code should perform any inventory or manual counting. Basing your algorithms off such fixed numbers complicates things, and is demonstrative of a more controlling nature.
  • 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.
    • Commenting will be rated on the following scale (worth 3 total points):
      • 3/3: Aesthetically pleasing (comments aligned or generally not distracting), easy to read, organized
      • 2/3: Mostly consistent, some distractions or gaps in comments (not explaining important things)
      • 1/3: Light commenting effort, not much time or energy appears to have been put in.
      • 0/3: No original comments
    • Sufficient comments explaining the point of provided logic MUST be present
  • Code must be appropriately modified
    • Appropriate modifications will be rated on the following scale (worth 3 total points):
      • 3/3: Complete attention to detail, original-looking implementation
      • 2/3: Lacking some details (like variable initializations), but otherwise complete (still conforms, or conforms mostly to specifications)
      • 1/3: Incomplete implementation (typically lacking some obvious details/does not conform to specifications)
      • 0/3: Incomplete implementation to the point of non-functionality (or was not started at all)
    • Error checking must be adequately and appropriately performed, according to the following scale (worth 3 total points):
      • 3/3: Full and proper error checking performed for all reasonable cases, including queries for external resources and data.
      • 2/3: Enough error checking performed to pass basic project requirements and work for most operational cases.
      • 1/3: Minimal error checking, code is fragile (code may not work in full accordance with project requirements)
      • 0/3: No error checking (code likely does not work in accordance with project requirements)
  • Any and all non-void functions written must have, at most, 1 return statement
    • points will be lost for solutions containing multiple return statements in a function.
  • Absolutely, positively NO (as in ZERO) use of goto statements.
    • points will most definitely be lest for solutions employing such things.
  • Track/version the source code in a repository
  • Filling out any submit-time questionnaires
  • Submit a copy of your source code to me using the submit tool (make submit will do this) by the deadline.
haas/spring2016/hpc0/projects/dll0.txt · Last modified: 2015/10/25 22:15 by 127.0.0.1