Question

An Triangular matrix is a square matrix whose elements below the diagonal are defined to be...

  1. An Triangular matrix is a square matrix whose elements below the diagonal are defined to be 0. For example, the matrix element Mr,c = 0 if r > c. The following is an example matrix of size 4.

0

1

2

3

0

100

200

300

400

1

0

500

600

700

2

0

0

800

900

3

0

0

0

1000


While it is possible to use a regular 2D array to represent an Triangular matrix, doing so is wasteful with memory. Instead, we plan on creating an ADT that stores only the non-zero information as shown below:


   [0]      [1] [2]     [3] [4] [5]     [6] [7] [8] [9]

100

200

300

400

500

600

700

800

900

1000

   M0,0     M0,1    M0,2      M0,3     M1,1    M1,2     M1,3     M2,2     M2,3     M3,3

The basis of an effective ADT for an Triangular matrix requires two important computations:

Determine how many non-zero elements are required
Access function.

You are to write the following Python functions in a file named access.py that computes the access function for an Triangular. All of your functions should be O(1).

# Modify these functions. Add helper functions if you wish.

# These functions must be O(1).
def numNonZeros2DTriangular(N):
return 0
def access2DTriangular(N, row, col):
# return -1 if any parameters are nonsensical
return 0

Here are some examples of how your code should behave:

numNonZeros2DTriangular(4) → 10
numNonZeros2DTriangular(1) → 1
numNonZeros2DTriangular(5) → 15
access2DTriangular(4, 0, 0) → 0
access2DTriangular(4, 3, 3) → 9

access2DTriangular(4, 3, 0) → -1

YOU DO NOT HAVE TO IMPLEMENT THE ADT FOR TRIANGULAR MATRICES.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

Add a comment
Know the answer?
Add Answer to:
An Triangular matrix is a square matrix whose elements below the diagonal are defined to be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Table 1.2 1 4 5 6 Average 2 3 Investment A 400 300 500 200 100...

    Table 1.2 1 4 5 6 Average 2 3 Investment A 400 300 500 200 100 - 300 After tax benefits Value of Investment Jan 1 Dec 31 Average 200 ---- 1000 800 900 800 600 700 600 400 500 400 2000 300 100 --- 500 1 4 5 6 Average 2 3 Investment B 200 300 100 400 500 600 350 After tax benefits Value of Investment Jan 1 Dec 31 1000 833 917 833 666 750 666 499...

  • With reference to the Keynesian theory, if real GDP were $500 and government expenditure increased by...

    With reference to the Keynesian theory, if real GDP were $500 and government expenditure increased by $80, what would be the new real GDP? No information on multiplier was provided with this question. Expenditure (E) Possible equilibrium points E=Y 1000 900 800 C+I+G+NX 700 600 500 400 300 200 100 0 100 200 300 400 500 600 700 800 900 1000 GDP (Y)

  • Please answer question 4 to question 7. DEMAND/SUPPLY SCHEDULE 1                    DEMAND/SUPPLY SCHEDULE 2        &nbs

    Please answer question 4 to question 7. DEMAND/SUPPLY SCHEDULE 1                    DEMAND/SUPPLY SCHEDULE 2                                                                      Price Qd Qs Qd + 200 (at each price) Qs + 200 (at each price) $50 200 800 400 1000 $45 300 700 500 900 $40 400 600 600 800 $35 500 500 700 700 $30 600 400 800 600 $25 700 300 900 500 $20 800 200 1000 400 Assume a price floor of $45 in Schedule 1; what is the result? Assume a price ceiling...

  • Remaining Time: 1 hour, 08 minutes, 27 seconds. Question Completion Status: 1 2 3 4 5...

    Remaining Time: 1 hour, 08 minutes, 27 seconds. Question Completion Status: 1 2 3 4 5 6 7 8 9 10 11 12 Question 4 For a company that uses a year as its interest period, determine the net cash flow that will be recorded at the end of the year from the cash flows she Receipts, $1000 Month 500 800 200 Disbursements, $1000 300 500 400 400 500 600 120 600 Jan Feb Mar Apr May June July Aug...

  • With reference to the Keynesian theory and cross graph, if the real GDP were initially $900,...

    With reference to the Keynesian theory and cross graph, if the real GDP were initially $900, what would tend to happen to consumption expenditure? How would it change and why would it change? Why would it stop changing? Expenditure (E) Possible equilibrium points E=Y 1000 900 800 C+I+G+NX 700 600 500 400 300 200 100 0 100 200 300 400 500 600 700 800 900 1000 GDP (Y)

  • Price Quantity demanded Quantity supplied 1 700 300 2 600 400 3 500 500 4 400...

    Price Quantity demanded Quantity supplied 1 700 300 2 600 400 3 500 500 4 400 600 5 300 700 6 200 800 7 100 900 8 0 1000 ​ Suppose that the production of good X generates external value of $3 per unit (due to lowering production of cost of another good Y) for the economy. What is the value of the appropriate corrective tax or subsidy? a) Subsidy - $3 b) Subsidy - $2 c) Tax - $3...

  • Wondering if I could get some guidance on setting up newMatrix(). Language is C Matrix ADT...

    Wondering if I could get some guidance on setting up newMatrix(). Language is C Matrix ADT Specifications In addition to the main program Sparse.c and the altered List.c from pal, you will implement a Matrix ADT in a file called Matrix.c. This ADT will contain a private inner struct (similar to Node in your List ADT) encapsulating the column and value information corresponding to a matrix entry. You can give this inner struct any name you wish, but I will...

  • A. For the above prices and quantities: Which are the demand quantities and which are the supply quantities?

    1.            P            Q1              Q2              500          1000            100             1000          900             200             1500          800             300             2000          700             400             2500          600             500             3000          500             600             3500          400             700             4000          300             800             4500          200             900             5000          100            1000     A. For the above prices and quantities: Which are the demand             quantities and which are the supply quantities?     B. Graph demand and supply on one graph. (Plot the points)     C. What is the equilibrium price and quantity?         Approximately.      D. What would a price ceiling set at...

  • Total costs in the table are: Select one: a. decreasing at a decreasing rate. b. decreasing...

    Total costs in the table are: Select one: a. decreasing at a decreasing rate. b. decreasing at a constant rate. c. increasing at a constant rate. d. increasing at an increasing rate. | M Control variable e 0 Total Benefits B(Q) arginal Benefit MB(Q) Marginal Cost MC(Q) Marginal Net Benefit MNB(Q) 0 900 1,700 100 200 Total Costs C(Q) 0 100 300 600 1,000 1,500 2,100 2,800 B 4,500 5,500 Net Benefits N(Q) 0 800 C 1,800 2,000 2,000 1,800...

  • udent Name Report on Laboratory Experiment "Spectra" Continuous Spectra Incandescent 400 300 500 600 Fluorescent 800 300 400 500 Bright-line Spectra 600 800 HydrogenmtTT 800 700 600 500...

    udent Name Report on Laboratory Experiment "Spectra" Continuous Spectra Incandescent 400 300 500 600 Fluorescent 800 300 400 500 Bright-line Spectra 600 800 HydrogenmtTT 800 700 600 500 300 Helium 800 700 600 500 400 300 Neon 600 300 Argon 600 500 Wavelength, nm 400 300 QUESTIONS: 1. What is a spectrum? 2. ls white light a simple color or misture of a number of colors? All emission spectra are characteristic of the particular elements. That is, they are like...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT