Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1050683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:48:26+00:00 2026-05-16T16:48:26+00:00

Why is the memory of a 2d array accessed by two parameters and not

  • 0

Why is the memory of a 2d array accessed by two parameters and not just by one (ignoring pointers).Why is it that the memory diagram is in terms of rows and columns and not straight (horizontal),Further more why is it said that 2d array is a array of arrays but i dont get that .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:48:26+00:00Added an answer on May 16, 2026 at 4:48 pm

    It’s about convenience. Sure, the memory’s actually all sequential, but sometimes one wants to be able to access things with two indices (e.g. implementing matrices).

    Consider a 3×3 array. It’s convenient to think of the memory like this:

    ----------------------------
    | [0][0] | [0][1] | [0][2] |
    |--------------------------|
    | [1][0] | [1][1] | [1][2] |
    |--------------------------|
    | [2][0] | [2][1] | [2][2] |
    ----------------------------
    

    But in memory, it of course really looks like this:

    ----------------------------------------------------------------------------------
    | [0][0] | [0][1] | [0][2] | [1][0] | [1][1] | [1][2] | [2][0] | [2][1] | [2][2] |
    ----------------------------------------------------------------------------------
    

    We just split it up into rows so that we can easily understand it as two-dimensional. We access it with two parameters because we want to, because that’s convenient for our code. The language provides this implementation, which makes it possible to access via two indices, even though under the covers it’s linear and could be accessed with one index.

    This picture should also help you understand why it can be considered an array of arrays. Here’s a slightly modified picture, for emphasis:

    |||--------------------------|||--------------------------|||--------------------------|||
    ||| [0][0] | [0][1] | [0][2] ||| [1][0] | [1][1] | [1][2] ||| [2][0] | [2][1] | [2][2] |||
    |||--------------------------|||--------------------------|||--------------------------|||
    

    As you can see, there are really three one-dimensional arrays there. So, when you write array[1], you are referring to the second one-dimensional component of the full two-dimensional array, i.e. the second group of three in memory. Adding a second index, array[1][2] takes the third element of that one-dimensional array, getting you down to a single element of the two-dimensional array as desired.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just curious if I'm creating a shared memory array on Windows platform like so:
I understand that when I declare a shared memory array in a kernel, the
say I have 3 share memory array: a b c. I am not sure
I'd like to create an in-memory array variable that can be used in my
I'm wondering if I am managing the memory of an Array correctly. Below I
I don't understand how to Dynamic allocate memory for an array of structs within
I have a little bit seen the representation of an array in memory with
I have an array of bytes, in memory. What's the fastest way to see
I have Fortran-based 3D column-major order array flattened into linear memory. What formula/algorithm can
I am wondering how I can load a byte array into a memory URLClassLoader?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.