Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this programming assignment. Development plan 1. Create a directory (folder) to hold assignment 4. Put all of the files for this

I need help with this programming assignment.

Development plan

1. Create a directory (folder) to hold assignment 4. Put all of the files for this assignment in that directory.

2. Create a file called equiv.cpp. Copy and paste the template into it. Edit the file. Add your name and the assignment number. If you will use tabs, say how far apart the tab stops are.

3. Write a comment telling what this module will provide when it is finished.

4. Create a file called equiv.h. Copy the following into equiv.h, then edit it to add your name.

// CSCI 2530 // Assignment: 3 // Author: *** // File: equiv.h // Tab stops: none // These #ifndef and #define lines make it so that, if this file is // read more than once by the compiler, its body is skipped on all // but the first time it is read. #ifndef EQUIV_H #define EQUIV_H // An equivalence relation is an array of integers. // So ER abbreviates int*. typedef int* ER; // Public functions ER newER (const int n); void destroyER (ER R); bool equivalent (ER R, const int x, const int y); void merge (ER R, const int x, const int y); // The following is advertised here solely for debugging. These must // only be used for debugging. void showER(const ER R, const int n); int leader(ER R, const int x); #endif 

Note. In the types of equivalent and leader, parameter R is not marked const, even though it seems to make sense to do that. The reason is that improvements that can be done for extra credit need to make changes to R, even in equivalent and leader.

5. In equiv.cpp, write a contract, then an implementation, of the newER function. Notice that newER(n) returns an equivalence relation that can handle set {1, 2, , n}. Say that. Don't say that it returns an array.

6. In equiv.cpp, write a contract, then an implementation, of the showER function. Pay attention to what showER is supposed to do.

7. Create file testequiv.cpp. Add a main function to it, and make main create a new ER (using newER) and show that ER (using showER). Testequiv.cpp should contain

#include "equiv.h" 
to allow it to use what is described in equiv.h.

8. In equiv.cpp, write a contract, then an implementation, of the leader function. Modify testequiv.cpp so that it tests leader. Note that, at this point, each number will be its own leader. Run testequiv.cpp.

9. In equiv.cpp, write a contract, then an implementation, of the merge function. Modify testequiv.cpp so that it performs some merge operations and shows the equivalence relation after each merge. Run testequiv.cpp. Check the results.

10. In equiv.cpp, write a contract, then an implementation, of the equivalent function. Modify testequiv.cpp so that it shows equivalences after merge operations. Run testequiv.cpp. Check the results.

11. In equiv.cpp, write a contract, then an implementation, of the destroyER function. Modify testequiv.cpp so that it destroys an ER array. Run testequiv.cpp. Check the results.

12. Check your program. Proofread your contracts. Look for spelling and grammatical errors. Ensure that you have paid attention to the issues to be aware of.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions