User Tools

Site Tools


Sidebar

projects

hfi0 (due 20170117)
wcp1 (due 20180117)
osi0 (due 20180124)
wcp2 (due 20180124)
osi1 (due 20180131)
wcp3 (due 20180131)
osi2 (due 20180207)
wcp4 (due 20180207)
haas:spring2018:hpc0:projects:dll2

Corning Community College

CSCS2320 Data Structures

~~TOC~~

Project: DLL2

Errata

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

  • revision #: <description> (DATESTAMP)

Objective

This is a transitional project, making a few modifications to the list struct forcing some changes to a few functions so that we can better explore the next topic (in dls0).

As such, while this is a standalone project, it should be considered a small one, and one that is given out in combination with another (again: dls0), so be mindful of time management.

You will need to complete this project prior to upgrading to dls0.

Project Overview

list.h

For this project, we need to make a modification to the list struct (which you can also check out in inc/list.h):

struct list {
    Node              *first;               // pointer to start of list
    Node              *last;                // pointer to end of list
    ulli               qty;                 // quantity of nodes in list
};

Specifically, we now have a qty variable, which will keep track of the number of nodes in the list.

To implement qty, all list functions that perform manipulations to the list will need to see some updating (mklist(), insert(), append(), and obtain()). Functions like cplist() should be using the aforementioned functions to manipulate the list, so it does not need any changes (if your cplist() is redundant, it will need to see changes to ensure compatibility).

list library

Again, in src/list/, you are to add support for qty so that, just as the list's first and last maintain an accurate positioning of their respective aspects of the list, qty maintains a count of the total number of nodes still in the list.

display() enhancements

You are also to implement 4 additional modes to the display() function.

Be sure to adjust any mode error correction accordingly.

The modes are as follows:

//////////////////////////////////////////////////////////////////////
//
// Options for list display() and support catlist() functions
//
#define  DISPLAY_FORWARD     000
#define  DISPLAY_NOPOSVALS   000
#define  DISPLAY_NOASCII     000
#define  DISPLAY_SEPS        000
#define  DISPLAY_POSVALS     001
#define  DISPLAY_BACKWARD    002
#define  DISPLAY_ASCII       004
#define  DISPLAY_NOSEPS      010

What has changed? There are two additional toggles:

  • NOASCII/ASCII - whether or not to render VALUE as an ASCII character or a number
    • in ASCII mode, separators become commas, and the terminating NULL no longer is output
  • SEPS/NOSEPS - whether or not to display arrows/commas or nothing at all

For example, if there was a numeric 65 stored in the node, with DISPLAY_ASCII set, an 'A' should be displayed instead of a 65.

display() output examples based on mode

Let's say we have a list with the following elements:

first -> 51 -> 49 -> 51 -> 51 -> 55 -> NULL
forward, no positions, with separators, as numbers (not ASCII)
51 -> 49 -> 51 -> 51 -> 55 -> NULL
forward, with positions, with separators, as numbers (NOT ASCII)
[0] 51 -> [1] 49 -> [2] 51 -> [3] 51 -> [4] 55 -> NULL
forward, no positions, with separators, in ASCII
'3' -> '1' -> '3' -> '3' -> '7' -> NULL
forward, with positions, with separators, in ASCII
[0] '3' -> [1] '1' -> [2] '3' -> [3] '3' -> [4] '7' -> NULL
forward, no positions, no separators, in ASCII
31337

Please see the unit test for more information.

List library applications

cyclecheck

A problem that cropped up from time to time during the list implementation was the instance of a list cycle, where a node accidentally ended up pointing to itself (or a previous location, to the direction of traversal). This led to seemingly “infinite loops” as streams of identical values displayed on the screen, and hopefully pictures drawn to try and track down the source of the problem.

With the doubly-linked list functions (especially insert() and append()) we baked in additional resiliency by having them check the validity of their place pointers, to ensure that place was a legitimate node in the list.

But we've not done anything to address the presence of cycles. Here we will explore how to detect them, and even attempt to ascertain where they start (source) and at what point the list repeats (destination) over and over again.

Expected Results

To assist you in verifying a correct implementation, a fully working implementation of the node library, list library (with new modifications), and group library should resemble the following:

list library

dll2 list functions

Here is what you should get for the specific functions relevant to dll3:

lab46:~/src/data/dll2$ make check
======================================================
=    Verifying Doubly-Linked  List Functionality     =
======================================================
    [mklist] Total:  18, Matches:  18, Mismatches:   0
    [append] Total:  47, Matches:  47, Mismatches:   0
    [insert] Total:  47, Matches:  47, Mismatches:   0
    [obtain] Total:  71, Matches:  71, Mismatches:   0
   [display] Total:  54, Matches:  54, Mismatches:   0
======================================================
   [RESULTS] Total: 237, Matches: 237, Mismatches:   0
======================================================
lab46:~/src/data/dll2$ 

entire list

Here is what you should get for all the functions completed so far in the list library (dll0+dll1+dll2):

lab46:~/src/data/dll2$ bin/verify-list.sh
====================================================
=    Verifying Doubly-Linked List Functionality    =
====================================================
  [mklist] Total:  18, Matches:  18, Mismatches:   0
  [cplist] Total:  18, Matches:  18, Mismatches:   0
  [rmlist] Total:   7, Matches:   7, Mismatches:   0
   [empty] Total:   7, Matches:   7, Mismatches:   0
  [append] Total:  47, Matches:  47, Mismatches:   0
  [insert] Total:  47, Matches:  47, Mismatches:   0
  [obtain] Total:  71, Matches:  71, Mismatches:   0
 [display] Total:  54, Matches:  54, Mismatches:   0
    [find] Total:  28, Matches:  28, 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: 388, Matches: 388, Mismatches:   0
====================================================
lab46:~/src/data/dll2$ 

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/spring2018/hpc0/projects/dll2.txt · Last modified: 2015/11/08 13:34 by 127.0.0.1