CSC161 2011S Imperative Problem Solving
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
Summary:
Prerequisites: Familiarity with arrays, stacks, and queues.
a. Create a directory for this lab. I would suggest
CSC161/Labs/Linear.
b. Copy files from Examples/Linear. You can copy files individually, or just copy the tarball.
a. Read through linear.h to make sure that you understand
the basic operations we are providing in linear structures.
b. Read through the code of linear-expt.c and predict what
output you should get for a stack.
c. Read through the code of linear-expt.c and predict what
output you should get for a queue.
a. Read through the code of array-stack.c to ensure that
you understand the parts. Make note of any potential problems or errors
you observe.
b. Make and run array-stack-expt.
c. If all goes well (and I hope it will), you should see that these stacks work correctly.
a. Read through the code of array-queue.c to ensure that
you understand the parts. Make note of any potential problems or errors
you observe.
b. Make and run array-queue-expt.
c. You are likely to observe the experiment segfault. Why? Because
there's an error in add that doesn't handle the end of the
array. In the standard design, if the tail has reached the end of the
array, it should wrap around to the beginning. Updated add
to ipmlement that strategy.
d. Review array-queue.c to note any other potential problems
or errors. You may wish to correct them now.
e. Make and run array-queue-expt. If you have not fixed it
already, you are likely to encounter an error because get
also has the wrap-around problem. Fix it.
f. Review array-queue.c to note any other potential problems
or errors. You may wish to correct them now.
g. Make and run array-queue-expt. There'also an error with
clear that you may or may not have fixed. If you have not
fixed it already, fix it.
h. You may have noted that is_empty and is_full
were not written. If you haven't done so already, write them.
There is some code that only runs if the ADDITIONAL_TESTS flag
is set. Either compile with that flag set or remove the #ifdef
and #endif lines.
a. What difference do you expect this change to make in each progrma?
b. Check your answer experimentally.
c. If you've found that the code revealed a new error, fix that error.
Wednesday, 4 May 2011 [Samuel A. Rebelsky]
Thursday, 5 May 2011 [Samuel A. Rebelsky]
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Labs/array-structures-lab.html.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri May 6 11:24:58 2011.
The source to the document was last modified on Fri May 6 11:24:56 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Labs/array-structures-lab.html.
A PDF version of this document may be found at
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Labs/array-structures-lab