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

Questions Cloud

Perform an analysis of tjs product-mix problem : Perform an analysis of TJ's product-mix problem, and prepare a report for TJ's president that summarizes your findings. Be sure to include information and analysis.
Constructing a confidence interval for a mean : What is meant by the term "90% confident" when constructing a confidence interval for a mean?
Typical firm in hong kong : Using the Internet, library, or other resources, research and briefly explain 2-3 methods currently being used to encourage economic growth for the typical firm in Hong Kong and for the typical firm in Singapore.
Suppose you bought a bond with a coupon rate : Suppose you bought a bond with a coupon rate of 8.9 percent one year ago for $912. The bond sells for $956 today. Required: (a) Assuming a $1,000 face value, what was your total dollar return on this investment over the past year? What was your total..
Implement a class that supports an extendable variant : 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
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.

Reviews

Write a Review

 

C/C++ Programming Questions & Answers

  What is the output of the corrected loop

What is the output of the loop as it is written and correct the syntax of the loop so that the logic of the corrected loop corresponds to the formatting of the original loop. What is the output of the corrected loop?

  Create a program that uses the vanderwaals equation

Write a program that uses the VanderWaals equation of state and the perfect gas law to display in tabular form the relationship between the pressure and the volume of n moles of a gas at a constant absolute temperature, T, over a range of volumes.

  Consider the following function

Consider the following function:  Which of the following would be the best way to call this function?

  Catch clauses are listed is important

write a program that can be used to demonstrate that the order in which catch clauses are listed is important

  Class mail order

Set up one one-dimensional array for each field: product number (integer), unit price (double), and current inventory level (integer) in main memory to hold the above product information. There should be five rows (0 to 4) in each array, one for e..

  Multiplying the current balance

The interest is calculated by multiplying the current balance, rate and time period which is one quarter of a year as in this case. A new balance is calculated by adding that interest.

  Program to produce ten random permutations of numbers

In C++(must be able to compile in Visual Studio ): Write a program to produce ten random permutations of numbers 1 to 10.

  Determine the other operations

(a) {C2(z), C2(x)}, determine the other operations that must be present to form a complete point group. [Hint: Consider all of the products of the given elements with themselves and each other.]

  Wrie a program that will generate a list of 10000 numbers

Wrie a program that will generate a list of 10000 numbers stored in an array with values 1 and 500.Print out any original 200 numbers to show the results(not one number per line either).Now sort the number using bubble sort

  Write a c program to search a list of integers

Write a C program to search a list of integers for a particular value. The user should be prompted to enter the value to be searched for. Your program will then print out whether the value was found or not.

  Programming assignment is to tweak the existing mammal

programming assignment is to tweak the existing Mammal program and create your own Vehicle program.

  C programs hat print out the max, min, and the average value

Write three C programs that print out the max, min, and the average values of the data file included below. Be sure to include the outputs of the programs in your solutions. Use three data file structures (counter, sentinel, and neither counter/senti..

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