User Tools

Site Tools


Sidebar

projects

haas:fall2014:data:projects:node1

This is an old revision of the document!


Corning Community College

CSCS2320 Data Structures

~~TOC~~

Project: NODE1

Errata

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

  • no updates yet

Objective

To continue getting acclimated to this whole 'node' thing, and to further familiarize ourselves with the project directory tree.

Reference

If you haven't done so yet, you absolutely, positively, MUST watch this video: http://www.youtube.com/watch?v=5VnDaHBi8dM

Procedure for bootstrapping

Obtain

On Lab46, change into your node0 directory (I'll use ~/src/data/node0/ in my examples):

lab46:~$ cd src
lab46:~/src$ cd data
lab46:~/src/data$ cd node0
lab46:~/src/data/node0$ 

At this point you should be completed with the node0 project.

If you are done, and a make help shows an upgrade-node1 option being available, we can proceed with bootstrapping the node1 project:

lab46:~/src/data/node0$ make upgrade-node1
make[1]: Entering directory '/home/username/src/data/node0/src'
make[2]: Entering directory '/home/username/src/data/node0/src/node'
rm -f *.swp *.o  core
make[2]: Leaving directory '/home/username/src/data/node0/src/node'
make[1]: Leaving directory '/home/username/src/data/node0/src'
make[1]: Entering directory '/home/username/src/data/node0/testing'
make[2]: Entering directory '/home/username/src/data/node0/testing/node'
make[3]: Entering directory '/home/username/src/data/node0/testing/node/app'
rm -f *.swp *.o ../../../bin/node-app-display node-app-test2 node-app-test core
make[3]: Leaving directory '/home/username/src/data/node0/testing/node/app'
make[2]: Leaving directory '/home/username/src/data/node0/testing/node'
make[1]: Leaving directory '/home/username/src/data/node0/testing'
Archiving the project ...
Compressing the archive ...
Setting Permissions ...
You may now switch to the ../node1 directory
lab46:~/src/data/node0$ 

As you can see from the last line: You may now switch to the ../node1 directory

So let's do it:

lab46:~/src/data/node0$ cd ../node1
lab46:~/src/data/node1$ 

Overview

Just as before, you'll see various files and directories located here (one regular file, Makefile, and 5 directories). The directory structure (note, not all these directories may yet be present, although a few more are here than were in the node0 project) for the project is as follows:

  • bin: compiled, executable programs will reside here
  • inc: project-related header files are here
  • lib: compiled, archived object files (aka libraries) will reside here
  • src: subdirectory tree containing our Data Structure implementations
    • node: location of our node implementation (NEW in this project)
    • list: location of our linked list implementation (manipulation of nodes)
    • stack: location of our stack implementation (manipulation of lists)
    • queue: location of our queue implementation (a different manipulation of lists)
  • testing: subdirectory tree containing our test apps and unit tests
    • node: node-related testing files will be here
      • app: end-user applications, demonstrating use (NEW files in this project)
      • unit: unit tests, helping to verify correct implementation (NEW in this project)
    • list: list-related testing files
      • app: end-user applications, demonstrating use
      • unit: unit tests, helping to verify correct implementation

Operating

The project is driven by a fleet of optimized Makefiles, which will facilitate the compiling process for us.

Each Makefile plays a unique role (the closer the Makefile is to the source code, the more specialized it becomes).

The base-level Makefile is used to enact whole-project actions, such as initiating a compile, cleaning the project directory tree of compiled and object code, submitting projects, or applying bug-fixes or upgrading to other projects.

Running make help will give you a list of available options:

lab46:~/src/data/node1$ make help

****************[ Data Structures List Implementation ]*****************
** make                     - build everything (libs and testing)     **
** make debug               - build everything with debug symbols     **
**                                                                    **
** make libs                - build all supporting libraries          **
** make libs-debug          - build all libraries with debug symbols  **
** make testing             - build unit tests                        **
** make testing-debug       - build unit tests with debugging symbols **
**                                                                    **
** make save                - create a backup archive                 **
** make submit              - submit assignment (based on dirname)    **
** make update              - check for and apply updates             **
**                                                                    **
** make clean               - clean; remove all objects/compiled code **
** make help                - this information                        **
************************************************************************
lab46:~/src/data/node1$ 

In general, you will likely make the most frequent use of these options:

  1. make: just go and try to build everything
  2. make debug: build with debugging support
  3. make clean: clean out everything so we can do a full compile

Most of what you do will be some combination of those 3 options.

Project Submission

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

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

Bugfixes and Updates

Sometimes, a typo or other issue will be uncovered in the provided code you have. I will endeavor to release updates which will enable you to bring your code up-to-date with my copy.

When a new update is available, you will start seeing the following appear as you go about using make:

lab46:~/src/data/node1$ make
*********************************************************
*** NEW UPDATE AVAILABLE: Type 'make update' to apply ***
*********************************************************
...
lab46:~/src/data/node1$ 

When this occurs, you may want to perform a backup (and/or commit/push any changes to your repository)– certain files may be replaced, and you do not want to lose any modifications you have made:

lab46:~/src/data/node1$ make save
Archiving the project ...
Compressing the archive ...
Setting Permissions ...
lab46:~/src/data/node1$ 

Once you have done that, go ahead and apply the update (note this output is from the node0 project update, so you will not see the exact same output):

lab46:~/src/data/node1$ make update
Update 1 COMMENCING
Update 1 CHANGE SUMMARY: Fixed base and other Makefile typos
    Please reference errata section on project page for more information
Update 1 COMPLETE
Updated from revision 0 to revision 1
lab46:~/src/data/node1$ 

At this point your code is up to date (obviously the above output will reflect whatever the current revision is).

upgrades

As the semester progresses, additional projects will be made available. When this occurs, you may notice new entries appear on the make help display. For example, as the deadline for the node1 project approaches, you will see the following appear:

...
** make update              - check for and apply updates             **
** make upgrade-sll0        - upgrade to next project (sll0)          **
**                                                                    **
** make clean               - clean; remove all objects/compiled code **
...

By typing make upgrade-sll0, your current work on node1 will be copied into a new sll0 directory (peer to node1), and any new files will be copied in from its project directory in /var/public/data/fall2014/sll0/

As such, it is most advisable to have completed work on node1 before upgrading to the sll0 project, so any work you've done will be immediately available to build upon in the next project (the projects will be comprehensive to one another– sll0 will rely on work completed in node1, sll1 (the project after sll0) will rely on the work done in sll0, etc.).

Project Task

In testing/node/app/, you will find a file called: node-app-display.c

Take a look at the code already there. Figure out what is going on, make sure you understand it. It builds a list of nodes based on user input.

If you look at the bottom of the program, you'll see the following comment:

    // Display list from start to end

It is here I would like for you to add code that will display the contents of this arbitrary list of nodes, from beginning to end.

Building the code

You've made changes to node-app-display2.c, and are ready to see your results. What do we do?

First, let's have a second terminal open and logged into lab46. Put it in the base directory of the node1 project:

lab46:~$ cd src/data/node1
lab46:~/src/data/node1$  

Keep your other terminal in the ~/src/data/node1/testing/node/app/ directory, so you can more effectively make changes.

cleaning things out

If you've already ran make to build everything a few times, you may want to clean things out and do a fresh compile (never hurts, and might actually fix some problems):

lab46:~/src/data/node1$ make clean
make[1]: Entering directory '/home/user/src/data/node1/src'
make[2]: Entering directory '/home/user/src/data/node1/src/node'
rm -f *.swp *.o cp.o mk.o rm.o core
make[2]: Leaving directory '/home/user/src/data/node1/src/node'
make[1]: Leaving directory '/home/user/src/data/node1/src'
make[1]: Entering directory '/home/user/src/data/node1/testing'
make[2]: Entering directory '/home/user/src/data/node1/testing/node'
make[3]: Entering directory '/home/user/src/data/node1/testing/node/app'
rm -f *.swp *.o ../../../bin/node-app-arrtolist node-app-display2 node-app-display node-app-test2 node-app-test3 node-app-test core
make[3]: Leaving directory '/home/user/src/data/node1/testing/node/app'
make[3]: Entering directory '/home/user/src/data/node1/testing/node/unit'
rm -f *.swp *.o ../../../bin/unit-cpnode unit-mknode unit-rmnode core
make[3]: Leaving directory '/home/user/src/data/node1/testing/node/unit'
make[2]: Leaving directory '/home/user/src/data/node1/testing/node'
make[1]: Leaving directory '/home/user/src/data/node1/testing'
lab46:~/src/data/node1$ 

compile project

Next, compile the whole project

lab46:~/src/data/node1$ make
...

Our binaries

Compiled executables go in the bin directory, so if we change into there and take a look around we see:

lab46:~/src/data/node1$ cd bin
lab46:~/src/data/node1/bin$ ls
node-app-display  node-app-test  node-app-test2
lab46:~/src/data/node1/bin$ 

Run the program

To run node-app-display, we'd do the following (specify a relative path to the executable):

lab46:~/src/data/node1/bin$ ./node-app-display2

The program will now run, and do whatever it was programmed to do.

Sample Output

For example, let's say we ran the program and put the values 6, 17, 23, 4, 56, and 2 in the list. Your completed program would look like this when run:

lab46:~/src/data/node1/bin$ ./node-app-display2
Enter a value (-1 to quit): 6
Enter a value (-1 to quit): 17
Enter a value (-1 to quit): 23
Enter a value (-1 to quit): 4
Enter a value (-1 to quit): 56
Enter a value (-1 to quit): 2
Enter a value (-1 to quit): -1
6 -> 17 -> 23 -> 4 -> 56 -> 2 -> NULL
lab46:~/src/data/node1/bin$ 

NOTE: This is just example input. Not only should your program work with this, but lists of any length, containing any arrangement of valid values.

NOTE2: The output of node-app-display2 should be pretty much identical to that of node-app-display, as only the method of arriving at the (same) solution has changed.

Your task

You are specifically responsible for creating this line of output:

6 -> 17 -> 23 -> 4 -> 56 -> 2 -> NULL

It needs to work for whatever values are put in the list (which can range from 0 to infinite values).

You need to display the node's contents, and separate that from the next bit of information with a space separated “→”, to help show the continuity of nodes we've joined together.

Finally, when you have exhausted your list, display a terminating “NULL” to visually signify the completion of the task.

Submission Criteria

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

  • Code must compile cleanly (no warnings or errors)
  • Executed programs must display in a manner similar to provided output
  • Processing must be correct based on input given and output requested
  • Output must be correct (i.e. the list visualization) based on values input
  • Code must be nicely and consistently indented (you may use the indent tool)
  • Code must be commented
  • 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/fall2014/data/projects/node1.1411334320.txt.gz · Last modified: 2014/09/21 21:18 by wedge