문제

Well, the title says it. Does a one-dimensional array have a direction? Or is the direction of a one dimensional array undefined?

Or maybe stated differently: when visualizing a one-dimensional array, should you visualize it top-down or left-right? Or is this arbitrary?

Does it depend on the programming language?

도움이 되었습니까?

해결책 2

Depending on if it's key value pair it could or it couldn't have a direction. If you assign an array like this

a[0]='something'
a[1]='something else'
a[2]='something something else'

Then it definitely looks like it has a direction. Versus something like this

a['foo']='bar'
a[5]='five'
a['a']=1

If you're talking about how the array is actually stored in memory then that's a different story. I can't remember exactly from my CS classes but I'm pretty sure that the data in an array is stored randomly and just terminated with a pointer to the next part of the array. Don't quote me on that though.

다른 팁

If you mean something like is a 1D array a row-vector or a column-vector ? then the answer is it depends.

Matlab, for example, recognises that a 1 x m vector is not the same as an m x 1 vector.

Fortran, on the other hand, does not recognise the distinction.

I'm sure other languages have their own conventions too.

As for mathematics, the usual convention (in the areas I am familiar with) is that vectors are column-vectors.

Take your pick.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top