Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Array Data Structure
course content

Course Content

Algorithms and Data Structures Overview

Array Data StructureArray Data Structure

An array is a fundamental data structure in computer science used to store a collection of elements, such as numbers, characters, or objects, of the same data type. Arrays offer a way to organize and access data efficiently by storing elements in contiguous memory locations and providing indexed access to each element.

Each element can be accessed using its index in an array. Since computers operate with memory addresses, knowing the index of an element allows us to calculate its address using the following formula:
begin_of_array_address + index_of_element * size_of_element.

  • begin_of_array_address: This represents the memory address of the beginning of the array. It indicates the starting point in memory where the array is stored;
  • index_of_element: This variable represents the index or position of the element we are interested in within the array. It denotes the element's location relative to the array's beginning;
  • size_of_element: This variable signifies the size or length of each element in the array, typically measured in bytes. It indicates the amount of memory occupied by each element in the array.

The time complexity of this operation is O(1), and this is the main feature of arrays that if we know the index, we can access the given element in contrast time.

In Python, real arrays aren't implemented natively. To use this data structure we have to import NumPy library:

question-icon

An array can store different types of objects.

Select the correct answer

Everything was clear?

Section 2. Chapter 1
some-alt