Implement a class that supports an extendable variant

Assignment Help C/C++ Programming
Reference no: EM13919391

In this exercise you will practice basic C++ class construction, and memory allocation and deallocation. You are asked to implement a class that supports an extendable variant of a sparse matrix (look it up). A matrix is a two-dimensional array. A matrix is sparse when many positions in the array are not important. In usual sparse matrices entries are not important when they are 0. In our version of the saprse matrix we distinguish between existing positions and not existing positions. Existing positions in our sparse matrices could contain the entry 0. In both cases, allocating memory to the unimportant positions in the matrix is a waste of memory. You could think about a database containing students and their grades in modules. Every row in the database corresponds to a student and every column corresponds to a module. Then, grades are to be stored only in modules that the student did take. The entry that corresponds to a module that the student did not take should not exist. In particular, 0 is a possible grade in a module that a student takes.

To summarize, you are going to implement a sparse matrix that stores integers (including 0) in some of the positions of a (relatively large) two-dimensional array. Technically, I have created the header file for the sparse matrix. You have to complete it with additional members. You will have to only submit two files: Sparse.cpp and Sparse.hpp. You will probably want to create your own main.cpp file that includes a program that actually executes your Sparse.cpp. You will not be submitting this file(main.cpp). I also supply a Makefile that you should (must) use for compilation. The Makefile includes a compilation of a main.cpp. The header file includes detailed descriptions of the functions that are required that you implement. Specific requirements: The way to implement this is by having a two-dimensional linked-list (look up linked-list). This essentially means that your matrix is a collection of cells (see the provided Cell.hpp and Cell.cpp) that are connected by pointers to the cells above, below, to their left, and to their right.

This means that your memory requirements are proportional to the number of elements stored in the matrix. Also, every operation that you perform will take time that is proportional to the number of elements in the matrix. The disadvantage of this option is that it is quite complicated to implement. Notice that I set up Cell to be ready for implementing a doubly linked list. Solutions implementing singly-linked data structures will not incur a penalty. However, they will provide fast access in one direction only. In any case, you have to implement the member function whatDidIImplement(). This function returns a value that identifies your solution in this case its "two-dimensional linked-list".

If your function returns a value that does not match your implementation strategy it could cost you up to 5 points. Materials provided: Cell.hpp Cell.cpp Sparse.hpp main.cpp - a small example prepared by Paula showing how to use Cells to create a linked list. main1.cpp - an alternative main file that includes a small test of Sparse. Prepared by Paula. mmain.cpp - compilation tester. Makefile tests.cpp - test cases Avoid Compilation Problems: In order to make sure that your program compiles you should put in a fresh directory your submission (Sparse.cpp, Sparse.hpp), the Makefile from above, Cell.cpp and Cell.hpp from above, and the file mmain.cpp from above. Change the name of mmain.cpp to main.cpp and compile using make. This should produce an executable called main. It will most likely crash (and that's fine). But it should compile! Operating Sytem Used Linux g++ complier.

Attachment:- Assignment.zip

Reference no: EM13919391

Previous Q& A

  Compute the percentage total return-capital gains yield

Suppose a stock had an initial price of $121 per share, paid a dividend of $3.30 per share during the year, and had an ending share price of $153. Compute the percentage total return. What was the dividend yield? What was the capital gains yield?

  An investment requires an initial outlay

An investment requires an initial outlay of $50,000, and is expected to generate cash flows of $13,000 a year for eight years. The required return is 11%. Determine the replacement chain NPV for this investment to compare it to a mutually exclusive a..

  Which investment do you recommend company undertake

Two investments, C and D are being evaluated. They are mutually exclusive. Investment C has a higher NPV using any discount rate between zero and 9%, while D has a higher NPV using any discount rate between 9.1% and 15%. Which investment do you recom..

  Solving simultaneous differential equations

In algebra, we often have to solve simultaneous differential equations. If the equations are linear and independent, there is a unique solution when the number of equations equals the number of variables.

  Evaluating two competing investments

A company is evaluating two competing investments. Investment X has a cost of $100,000 and a NPV estimated at $35,000. Investment Y has a cost of $220,000 and a NPV estimated at $35,500. Taking everything into account, you would recommend the company..

  Considering new equipment to run their service function

Grantran Metrics is considering new equipment to run their service function for their customers. This equipment would run faster and less expensively than equipment currently in place. This would be best characterized as:

  Cost of preferred stock

Duggins Veterinary Supplies can issue perpetual preferred stock at a price of $72.50 per share with an annual dividend of $4.50 a share. Ignoring flotation costs, what is the company's cost of preferred stock, rps?

  What was the most recent dividend per share paid on stock

Gontier Corporation stock currently sells for $64.93 per share. The market requires a return of 12 percent on the firm’s stock. If the company maintains a constant 5.5 percent growth rate in dividends, what was the most recent dividend per share paid..

  Using economic decision theory

Suppose you are considering either working through school or taking out loans. If you work at a 20 hour job at $15 per hour over 50 weeks per year, you can make $15,000, but it will take 5 years to graduate. How many years will it take to pay back th..

  Firm is trying to decide whether to produce new product

A firm is trying to decide whether to produce a new product. In order to produce this product, the firm would have to invest $4,906,000 in machinery and $490,600 in net working capital. The machinery would be depreciated using the 5-year depreciation..

Reviews

Write a Review

 

Similar Q& A

  Pre and post increament and decrement operators

We are going to overload the following operators in the fract class- pre and post increament (++) and decrement (--) operators

  Lists of integers and displays whether the two are identical

Write a test program that prompts the user to enter two lists of integers and displays whether the two are identical. Here are the sample runs.

  Write a parallel program with mpi

Write a parallel program with MPI that supports the computation - design own decomposition logic on the given problem, such as the number of processes produced, how and where to pass the result from one process to another etc.

  Generate the output below using the function

Make a C program that will generate the output below using the function that will pass the value into the function.

  Describes the application of the s4 symmetry operation

(a) Using its x, y, and z coordinates, construct a 15 × 15 matrix that describes the application of the S4 symmetry operation to [PtCl4]^2-.(b) What is the character of this matrix?

  Use selection sort to sort a[48] into increasing order

Use selection sort to sort A[48] into increasing order, and then print out the sorted list in four rows. There may be duplicates, but that's OK. (65 and 53 appear twice.) Duplicates will appear next to each other in the sorted list.

  By a minimal interpretation that makes a formula

By a minimal interpretation that makes a formula true, we mean that if one atom is removed from the interpretation then the resulting interpretation does no longer make the formula true.

  Create a bar chart showing the average monthly mean temperat

Write a ++ program to create a bar chart showing the average monthly mean temperature for College Station from 2004 to 2013. The point of the exercise is to compute the sie and location of the rectangles rather than explicitely hardcode that informat..

  You will write a program that reads a text file

You will write a program that reads a text file, counts the number of words in the file, and the number of occurrences of each character. It will print to a file the number of words, and the number of occurrences of each character, as well as the ..

  This project is to develop a program that implements a

this project is to develop a program that implements a hierarchical jpeg encoderdecoder for greyscale images.write your

  Write a program that will calculate the percentage

Write a program that will calculate the percentage wins of a team. The program will input the number of wins and losses that a team acquired during a season. The wins should be input in a parameter-less value returning function that returns the wi..

  Calculate the cost of carrying additional luggage results

The application used to calculate the cost of carrying additional luggage results in erroneous amount, if the weight of the luggage is a fractional number. Help the development team modify the code snippet so that the cost of carrying additional l..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd