Corning Community College
CSCS2320 Data Structures
With any increasingly complex piece of code or environment, we must find effective means of organizing various processes or communications. This “Errata” section and related updates are one such instance of that; intended as a means of disseminating information on changes to the project, you can be informed what modifications have taken place, along with any unique actions you need to take to compensate.
Any typos, bugs, or other updates/changes to the project will be documented here.
In this project, we get started with a simultaneous review opportunity for your programming skills, while introducing ourselves to one of the important underlying Data Structures concepts: lists.
In your programming travels so far, you've likely been exposed to the more tangible aspects of data; following will be some examples of different categories. If any are not familiar, please look them up and become more acclimated with the concept(s).
We have storage:
data types:
address types:
derived types:
signed attributes:
even representation:
… but now we'll be building on top of those. Data Structures is an exploration of both concept and strategic arrangement of information (and the related algorithmic approaches) to enhance your programming abilities.
We start out studying the concept known as the list, which is nothing short of a “number of connected items”. They come in various forms and manifestations, but before we get to those, we need to explore the concept.
For that we are going to utilize the hopefully familiar array, which will host (or encapsulate) your list, which will then be otherwise processed by program logic.
This is one of those “some lists are arrays, but not all arrays are lists” sort of thing, which will be touched on more in the coming projects.
As a means of simultaneous review, along with starting to acclimate ourselves to new concepts that we'll be encountering on a regular basis, I'd like for you to implement a program (in C) that does the following:
====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>>
The various menu options are described below:
>>> 0 enter value (-1 to finish): 2 enter value (-1 to finish): 4 enter value (-1 to finish): 6 enter value (-1 to finish): 8 enter value (-1 to finish): -1
There are two modes of list display you are to implement: that of displaying forward (from start to end) and that of its reverse (from end to start).
====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>> 1 [0] 2 -> [1] 4 -> [2] 6 -> [3] 8 -> [4] -1
====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>> 2 [4] -1 -> [3] 8 -> [2] 6 -> [1] 4 -> [0] 2
One of the two more “atomic” list addition options, insert is responsible for adding a value to the list BEFORE a referenced point.
====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>> 3 Enter index to insert before: 2 Enter value to insert into list: 5
If you were to display the list (forward) after doing this insert, you should have: 2 4 5 6 8 (we inserted the 5 before the current element 2 (containing the 6)).
The other of the “atomic” list addition options, append is responsible for adding a value to the list AFTER a referenced point.
====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>> 4 Enter index to append after: 3 Enter value to append into list: 7 ====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>> 1 [0] 2 -> [1] 4 -> [2] 5 -> [3] 6 -> [4] 7 -> [5] 8 -> [6] -1
In opposition to insert and append, which put items INTO the list, obtain does the opposite: it takes it out of the list.
====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>> 5 Enter index to obtain: 3 The value you obtained is: 6 ====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit >>> 1 [0] 2 -> [1] 4 -> [2] 5 -> [3] 7 -> [4] 8 -> [5] -1
The menu:
====ael0==== 0. build list 1. display list forward 2. display list backward 3. insert into list 4. append into list 5. obtain from list 6. clear list 7. quit
and prompt (note the trailing space after “>>> ”):
>>>
The menu and prompt are to go to STDERR, and NOT STDOUT. The output from running the various menu options (pretty much the display() function(s)) is to go to STDOUT.
The display option arrows are to take the form “ → ” (note the single space padded both before and after).
The index value is enclosed in square brackets (first one flush against left margin), followed by a space, then the array element (then the padded display arrow).
These output specifications play important roles, from facilitated program evaluation to testing how well you can code according to specifications (the latter a very important development skill to have).
In Data Structures precision and conformance to requirements will be increasingly important (not only for the scope of the project, but for your own sanity as deviating from it will likely make things far more difficult for you in implementation). Might seem a bit nitpicky, and on some level it is… but on others, a very important learning opportunity for the types of things you'll be encountering in the future.
In addition to writing this program, please be sure you brush up on (at least) the following:
A decent reference for the C programming language (and therefore many of the syntactical and conceptual structures found in languages like C++, Java, PHP, etc.) is:
When your program is functional, you can test it for correctness by using the projeval tool on lab46. A series of tests will be run, and you will be able to see if you program is in spec (SUCCESS) or out of spec (MISMATCH).
An example of a fully compliant test run follows:
lab46:~/src/data/ael0$ projeval ael0 [projeval] Evaluating ael0 for username [test 0] display 4 element populated list forward ... you have: [0] 2 -> [1] 4 -> [2] 6 -> [3] 8 -> [4] -1 should be: [0] 2 -> [1] 4 -> [2] 6 -> [3] 8 -> [4] -1 Result: SUCCESS! [test 1] inserting into empty list ... you have: [0] 7 -> [1] -1 should be: [0] 7 -> [1] -1 Result: SUCCESS! [test 2] appending into empty list ... you have: [0] 7 -> [1] -1 should be: [0] 7 -> [1] -1 Result: SUCCESS! [test 3] obtaining from 1 entry list ... you have: The value you obtained is: 7 should be: The value you obtained is: 7 Result: SUCCESS! [test 4] obtaining first entry from 2 entry list ... you have: The value you obtained is: 7 should be: The value you obtained is: 7 Result: SUCCESS! [test 5] obtaining second entry from 2 entry list ... you have: The value you obtained is: 8 should be: The value you obtained is: 8 Result: SUCCESS! [test 6] inserting before first entry in list ... you have: [0] 6 -> [1] 7 -> [2] -1 should be: [0] 6 -> [1] 7 -> [2] -1 Result: SUCCESS! [test 7] inserting before second entry in list ... you have: [0] 7 -> [1] 8 -> [2] 9 -> [3] -1 should be: [0] 7 -> [1] 8 -> [2] 9 -> [3] -1 Result: SUCCESS! [test 8] appending after last entry in list ... you have: [0] 7 -> [1] 8 -> [2] 9 -> [3] -1 should be: [0] 7 -> [1] 8 -> [2] 9 -> [3] -1 Result: SUCCESS! [test 9] appending after second to last entry in list ... you have: [0] 7 -> [1] 8 -> [2] 9 -> [3] -1 should be: [0] 7 -> [1] 8 -> [2] 9 -> [3] -1 Result: SUCCESS! [test 10] clearing list then appending ... you have: [0] 7 -> [1] -1 should be: [0] 7 -> [1] -1 Result: SUCCESS! [test 11] obtaining second entry from 2 entry list (check list integrity) ... you have: [0] 7 -> [1] -1 should be: [0] 7 -> [1] -1 Result: SUCCESS! [test 12] obtaining first entry from 2 entry list (checking list integrity) ... you have: [0] 8 -> [1] -1 should be: [0] 8 -> [1] -1 Result: SUCCESS! [test 13] obtaining from 1 entry list (checking list integrity) ... you have: [0] -1 should be: [0] -1 Result: SUCCESS! lab46:~/src/data/ael0$
To be successful in this project, the following criteria must be met:
Let's say you have completed work on the project, and are ready to submit, you would do the following (assuming you have a program called ael0.c):
lab46:~/src/SEMESTER/data/ael0$ submit data ael0 ael0.c Submitting data project "ael0": -> ael0.c(OK) SUCCESSFULLY SUBMITTED lab46:~/src/SEMESTER/data/ael0$
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.
I'll be evaluating the project based on the following criteria:
52:ael0:final tally of results (52/52) *:ael0:grabbed project by the Sunday before due date [6/6] *:ael0:clean compile, no compiler messages [10/10] *:ael0:runtime tests pass [20/20] *:ael0:adequate modifications [10/10] *:ael0:tracked in lab46 semester repo [6/6]
Additionally: