ARRAYS
Array is a data structure which holds same type of fixed number of data elements . Most of the other data structures like stack or queue make use of arrays to implement their algorithms .
Important terms in arrays : 1. Element : Each item stored in an array is called an element .
2.Index: Each location of an element in an array has a numerical index, which is used to identify the element.
Array declaration : In C , array is declared as below example .
Array can be declared in different ways in different languages .
Important points to be considered are :
- Index starts with 0 . (not 1 )
- In above example , array length is 10 , since it can store 10 elements .
- Each element can be accessed using it’s index . ( array[5] is element stored at index 5 in array , which is 19 )
Basic operations on an array :
- Insertion : Adding elements in an array at a given index.
- Deletion : Deletes elements in an array at a given index .
- Search : Searches an elements using either index or value .
- Traverse : Printing all elements in an array one by one .
- Update : Update an element at the given index .
When an array is initialized with size , then it assigns default values as 0 for all data types , false for boolean data type , and null for object type .
Get Shiny R . A’s stories in your inbox
Join Medium for free to get updates from this writer.
Advantages of an Array:
- We can put in place other data structures like stacks, queues, linked lists, trees, graphs, etc. in Array.
- Arrays can sort multiple elements at a time.
- We can access an element of Array by using an index.
Disadvantages of an Array :
- We have to declare Size of an array in advance. However, we may not know what size we need at the time of array declaration.
- The array is static structure. It means array size is always fixed, so we cannot increase or decrease memory allocation.
This is the introduction of Arrays .




