Arrays Flashcards

1
Q

What is an array?

A

Arrays is a data structure consisting of a collection of elements, each identified by a unique index.

  • The array can store data of a specified data types
  • Array stores data in contiguous cell
  • Array size is fixed
  • Every cell of an array has a unique index

Arrays can be

  • one-dimensional represented in one row with unique index
  • two-dimensional represented in [row(s)][column(s)]
  • three-dimensional represented in [depth(s)][row(s)][column(s)]
  • fourth-(n-dimensional): not used in real world

Use:

  • To store multiple of the similar data type of data
  • Random access is often

Avoid:

  • Data to be stored need to be homogenous
  • the limit is not known upfront
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is arrays stored in memory?

A

all dimensional array is stored at the physical level in a contiguous manner starting from the first cell and so on. Each cell will have a unique address assigned at the physical level that will map to a logical level.

i.e. arr = x102; arr will point to the first cell.

Array traversal starts with the first cell accessed by x102 + 0 address and the subsequent cell can be accessed with x102 + 1 and so on.

This is the reason the array needs to start with the 0th index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly