Questions tagged [multidimensional-array]

Multidimensional-arrays can be described as multi-dimensional tables. Each index used in order to find a given element is called a dimension.

An array is typically a data structure meant to store a collection of elements to which is associated a given index. These elements are often in contiguous memory locations although this is not a requirement.

Multidimensional-arrays can be described as multi-dimensional tables. Each index used in order to find a given element is called a dimension.

Depending on the programming language, such a data structure can be achieved through a specific multi-dimension array data structure or in the shape of an "array of arrays" (also known as jagged arrays or Iliffe vector).

Multidimensional-arrays are often used to put values in a table format (e.g. rows and columns).

Tutorials:

This StackOverflow thread provides some insight on the difference between multi-dimensional arrays and jagged arrays in C#.

Wikipedia article.

35247 questions
5
votes
3 answers

Pythonic way to generate random uniformly distributed points within hollow square lamina

Suppose we have a hollow square lamina of size n. That is, we have a nxn square from which a k*l rectangle has been removed (1<=k,l<=n-2). I want to calculate an average of distances between 2 random, uniformly distributed points within such hollow…
Nick Slavsky
  • 1,300
  • 3
  • 19
  • 39
5
votes
5 answers

Creating multidimensional arrays & matrices in Javascript

Trying to create a function mCreate() that given a set a numbers returns a multidimensional array (matrix): mCreate(2, 2, 2) // [[[0, 0], [0, 0]], [[0, 0], [0, 0]]] When this functions handles just 2 levels of depth ie: mCreate(2, 2) //[[0,…
cmdv
  • 1,693
  • 3
  • 15
  • 23
5
votes
6 answers

How to get the length of dynamically allocated two dimensional arrays in C

The question is how to get the length of dynamically allocated 2D Arrays in C? I thought the code below should get the number of rows, but it doesn't. char** lines; /* memory allocation and data manipulation */ int length; //the number of…
aminfar
  • 2,297
  • 3
  • 27
  • 37
5
votes
2 answers

Complex merge technique: How to transpose specific sets of data using a configuration array?

I've been struggling the whole day to create a merge function for a multidimensional array. The scenario is a little different and tricky to describe in words. Instead I will try to explain it with a practical example. $actual_array = [ …
5
votes
3 answers

Optimized "Multidimensional" Arrays in Ruby

From birth I've always been taught to avoid nested arrays like the plague for performance and internal data structure reasons. So I'm trying to find a good solution for optimized multidimensional data structures in Ruby. The typical solution would…
Justin L.
  • 13,510
  • 5
  • 48
  • 83
5
votes
3 answers

typescript multidimensional array with different types

I have an custom object declared (ThreadObj) and I want to create a THREADLISTS, holding multiple arrays of Threadlist. So Threadlist:ThreadObj[]=[]; THREADLISTS:[ThreadObj[]][ThreadObj]=[][]; //how to type and init? The first dim is of ThreadObj[]…
Han Che
  • 8,239
  • 19
  • 70
  • 116
5
votes
2 answers

How to count number of elements of a multidimensional array without using loop in PHP?

I have a an array like below: $array = Array ( '0' => Array ( 'num1' => 123, 'num2' => 456, ), '1' => Array ( …
Amit Rajput
  • 2,061
  • 1
  • 9
  • 27
5
votes
4 answers

Practical use of N-Dimensional Arrays,where (N>3)

I have been programming for the last 8 years and now I was just wondering that if there is any practical use of N-Dimensional array,where N>3.I can only visualize of a data structure that is less than or equal to 3 dimensions.Has any one used more…
Emil
  • 13,577
  • 18
  • 69
  • 108
5
votes
5 answers

Java - 2D array checking diagonal number board

Currently I'm working on a program that generates random 0's and 1's in a 8x8 2D array board. What I have to do is check whether or not if all the numbers on the diagonal are the same (starting from the corners, not just any…
Flinze
  • 131
  • 3
  • 4
  • 10
5
votes
1 answer

2-d array using Python's array.array module?

array.array is a built-in type, looks like it will be much more efficient than list for some numerical tasks. In numpy I could create a 2-d array easily, for example: a = numpy.asarray([[1,2][3,4]], dtype='int') But I couldn't find how to create a…
avocado
  • 2,615
  • 3
  • 24
  • 43
5
votes
1 answer

Python: NxM array of samples drawn from NxM normal distributions

I have two 2D arrays (or of higher dimension), one that defines averages (M) and one that defines standard deviations (S). Is there a python library (numpy, scipy, ...?) that allows me to generate an array (X) containing samples drawn from the…
5
votes
3 answers

Accessing rows of an array, inside an array of arrays?

Say i have: H = [array(a), array(b), array(c)...] a = [[1,2,3,4,5,6], [11,22,33,44,55,66], #row 1 of H[0] [111,222,333,444,555,666]] b = [[7,8,9,0,1,2], [77,88,99,00,11,22], [777,888,999,000,111,222]] c = ... I want to access…
layces
  • 161
  • 2
  • 2
  • 12
5
votes
2 answers

sort an array base on key

i have an array like this: Array ( [0] => Array ( [title] => some title [time] => 1279231500 ) [1] => Array ( [title] => some title 2 [time] => 1279231440 ) …
greenbandit
  • 2,267
  • 5
  • 30
  • 44
5
votes
1 answer

R subsetting and assigning in a multidimensional array

I am working with R with a 3D dimensional array. I am trying to use it like a set of 2D matrix for different time instants. I have find a behavior that I really don't understand and I will like to know why is happening. I have tried to find a…
Cohet
  • 80
  • 8
5
votes
4 answers

Iterating through fields in a Nodejs MySQL result set

I'm a relative node newbie (old school programmer) I have working code to grab a result set and parse through rows. I'm using felx's node-mysql driver. It's not hard to specifically print out columns. connection.query('SELECT * FROM Company',…
Barry Smith
  • 105
  • 1
  • 2
  • 10
1 2 3
99
100