Discuss memory representations of 1D and 2D arrays with the help of suitable example

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Discuss memory representations of 1D and 2D arrays with the help of suitable examples

Expert Solution
Step 1

One-Dimensional or Single-Dimensional array is considered as the ”list of variables of similar data types”, and each variable can be distinctly accessed by specifying its index in square brackets preceded by the name of that array.1d array

In C++, the declaration of an array variable with the size is enough to allocate space for them in memory. In Java, this is achieved in two steps. First, you must declare a variable of the desired type. Second, you must allocate the memory to hold the array using ‘new’ and assign it to the declared array variable. Hence, arrays are dynamically allocated in Java.

Step 2

Both C++ and Java support multidimensional array. One of the simplest forms of a multidimensional array is a two-dimensional array or 2-D array. A two-Dimensional array can be expressed as ‘array of arrays’ or ‘array of one-dimensional arrays’.

To declare the two-dimensional array variable, we have to specify the array name followed by two square brackets where the second index is the second set of square brackets.

A two-dimensional array is stored in the form of the row-column matrix, where the first index designates the row and second index shows the column. The second or the rightmost index of an array alters very fastly as compared to the first or left-most index while accessing the elements of an array.2d array

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY