c programming
//——————————————————————————
// INCLUDE GUARD
//——————————————————————————
#ifndef TABLE_H
#define TABLE_H
//——————————————————————————
// CONSTANTS AND TYPES
//——————————————————————————
typedef enum BOOL { false, true } boolean;
//——————————————————————————
// PROTOTYPES
//——————————————————————————
//————————————————–
// Add an element to the table
// [item]
// [boolean]
//————————————————–
boolean insertItem( int item );
//————————————————–
// Removes the int from the table
// [item]
// [boolean]
//————————————————–
boolean removeItem( int item );
//————————————————–
// Empty the table so that we clear all memory and can start a fresh table
//————————————————–
void clearTable( void );
//————————————————–
// Tells us whether or not the given item is in the table
// [item]
// [boolean]
//————————————————–
boolean search( int item );
//————————————————–
// Table iterators
// [item]
// [boolean]
//————————————————–
boolean firstItem( int * const item );
boolean nextItem( int * const item );
//——————————————————————————
// END OF INCLUDE GUARD
//——————————————————————————
#endif
set.h
#ifndef _SET_H
#define _SET_H
typedef enum BOOL { false, true } Boolean;
typedef struct SET Set;
// Returns true if there are currently *no* set objects in existence.
Boolean validateMemUse();
// Set constructor
Set * newSet();
//Set destructor
Set * deleteSet(Set * theSet);
// Insert an item into a set, noting that sets do not contain duplicate items.
// Returns true if the item was added to the set.
Boolean insertItem(Set * const theSet, const int newItem);
// Remove a given item, if it appears in the set.
// Returns true if the item was removed from the set.
Boolean removeItem(Set * const theSet, const int givenItem);
// Returns true if the two sets contain the same items.
Boolean equals(Set const * const setA, Set const * const setB);
// Return a new set that is the union of two sets (the two sets should be
// unchanged by the operation).
//
// The union of two sets A and B is defined to be another set
// containing all the items in A and all the items in B.
// (Note: Any item that is in BOTH A and B appears only once
// in the union, because no set contains duplicate items.)
// Example: If A = { 1, 2, 3 } and B = { 2, 4, 5, 6 }, then
// the union of A and B is the set { 1, 2, 3, 4, 5, 6 }.
Set * unionOf(Set const * const setA, Set const * const setB);
// Return a new set that is the intersection of two sets (the two sets should be
// unchanged by the operation).
//
// The intersection of two sets A and B is defined to be another set
// containing all the items in both A and B.
// Example: If A = { 1, 2, 3, 4 } and B = { 2, 3, 5 }, then
// the intersection of A and B is the set { 2, 3 }.
Set * intersectionOf(Set const * const setA, Set const * const setB);
// Return a new set that is the difference of two sets (the two sets should be
// unchanged by the operation).
//
// The difference (A\B) of two sets A and B is defined to be
// another set containing all the items in A that are NOT in B.
// Example: If A = { 1, 2, 3 } and B = { 2, 4, 5, 6 }, then
// the difference A\B of A and B is the set { 1, 3 }.
Set * differenceOf(Set const * const setA, Set const * const setB);
#endif
set1.o
set2.o
set3.o
COMP2160 Programming Practices
Assignment 3
Page 1 of 2
Due Date: March 14th at 11:59pm
NOTES
Please read and follow instructions carefully; not doing so will result in a loss of marks.
Your code must follow the programming standards (available in UMLearn).
You can write your code on any machines; remember to verify your code on one of the lab machines.
You must include a README file which describes how to compile and run your solution. You can
also explain your concerns or personal opinions regarding this assignment.
Use submission tool (handin) in CS Unix system as described in Assignment Submission
Guidelines (available in UMLearn).
Q1: DESIGN BY CONTRACT [10]
In this problem, you will create an implementation of the Table abstract data type (ADT). A Table is a data
type that allows for a few simple operations on a collection of data:
Insertion
Removal
Searching for presence
Iteration
Using the provided interface table.h and the sample linked list code linkedlist_int.c, complete
an implementation of the Table ADT. Make sure that you apply the concepts of design by contract (DbC) to
your implementation.
Once you have fully implemented the table, create a main.c file that implements a testing framework for
your table.
Your table implementation must ensure that values inserted are unique, and internally sorted in ascending
order (i.e., head points the lowest value) within a linked list. This is an implementation detail of your table,
and not part of the public interface. Be sure to only test what is known from the public interface (i.e., black
box testing).
Make sure you test with assertions turned off. Boundary conditions should not cause the program to crash.
Remember that to turn off assertions you can compile with -DNDEBUG.
Include a Makefile (along with all your source files) for your implementation.
COMP 2160 Programming Practices
Assignment 3
Page 2 of 2
Q2: SET (TESTING) [10]
You have been provided with a Set ADT developed by a third party. This consists of a header file, set.h,
defining the interface and the object file, coming soon (as a zip file), compiled for use in our Mac lab. You
must implement a complete unit test suite to validate all functionality defined in the header file.
Requirements and Notes
Hand in your main.c file (containing your test suite implementation) and a Makefile to compile your
code and link it with set.o.
You will be provided with, at least, two different object file implementations of Set. Include a report (in your
README file) for each object file, indicating whether they passed your tests or not. If an object file didn’t
pass your tests include all failure conditions that must be addressed in the README.
If, at any time, the code crashes then the problem is with your code. An object file may provide you with
erroneous results but will never cause your program to fail outright.
The test framework from question 1 should serve as a good foundation upon which to build the test
framework for this question.
Top-quality papers guaranteed
100% original papers
We sell only unique pieces of writing completed according to your demands.
Confidential service
We use security encryption to keep your personal data protected.
Money-back guarantee
We can give your money back if something goes wrong with your order.
Enjoy the free features we offer to everyone
-
Title page
Get a free title page formatted according to the specifics of your particular style.
-
Custom formatting
Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.
-
Bibliography page
Don’t pay extra for a list of references that perfectly fits your academic needs.
-
24/7 support assistance
Ask us a question anytime you need to—we don’t charge extra for supporting you!
Calculate how much your essay costs
What we are popular for
- English 101
- History
- Business Studies
- Management
- Literature
- Composition
- Psychology
- Philosophy
- Marketing
- Economics