THEORY.md 978 B

Array

What is an Array:

  • Array is a collection of objects or things of a similar type.
  • Arrays are one of the most used data structures in the world of computer science.

Properties of an Array:

  • Array can only store data of the same type.
  • Elements of an array are located in a contiguous fashion.
  • Each element of an array has a unique index.
  • The size of an array is predefined and cannot be modified.

Types of Array:

  1. One Dimensionsal
    • Example python array = [1, 2, 3, 4, 5]
  2. Multi-Dimensional
    • Example python array = [[1, 2 , 3], [4, 5, 6]] ### Array operations. 1. Create O(1) 1. Insertion O(1) 1. Traversal O(n), where n = array length 1. Accessing an element O(1) 1. Deletion O(1) Please note, the time complexity mentioned above is for a One-Dimensional Array. More about arrays can be found here.