Question: The 2-D array described in Chapter 2 is a simple rectan- gular structure consisting of the same number of elements in each row. Other layouts
The 2-D array described in Chapter 2 is a simple rectan- gular structure consisting of the same number of elements in each row. Other layouts are possible and sometimes required by problems in computer science. For example, the lower triangular array shown on the right is organized such that the rows are staggered with each successive row consisting of one more element than the previous row.
0 1 2 3 4
-
(a) Derive an equation that computes the total number of elements in the lower triangular table for a table of size m n.
-
(b) Derive an index equation that maps an element of the lower triangular table onto a one-dimensional array stored in row-major order.
-

Solve Exercise 3.11 on page 96 in your textbook. Your answer goes here Create as many CELLS as you need You may wish to conver the type of this cell from Markdown to Raw Click on this cell to write your answer (m(m+1))/2 Explanation : Given that the rows are staggered with each successive row consisting of one more element that previous row.Then row1 contain 1 element, row 2 contain 2 elements , row 3 contain 3 elements, and soon row m contains m elements. As we want to compute the total number of elements in the lower traingular table for a table of size m xn, we have to sum all of these which will result in 1 + 2 + 3 + ......... + m, Where m is the number of rows. It looks like sum of first m natural numbers and as we know the formula for this is (m(m+1))/2. So the Equation that computes the total number of elements in the lower triangular table for a table of size mxn is (m(m+1))/2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
