FOR FREE CONTENT

Array

Definition

Array (from programmer’s view) - “a consecutive set of memory locations” or in details, Array is

  • A linear data structure.
  • A contiguous allocated memory for the homogeneous data type.
  • An ADT is a set of pairs, <indexvalue>, such that each index is defined as a value associated with it (correspondence or mapping in mathematical terms).

So, being an ADT we will be more concerned with the operations that can be performed on an array. The array is useful for storing thousands of values in it and we access the values through the index. Usually, arrays are of fixed size.

 

Need of using Array

The efficiency of a computer lies in processing tens of thousands of data within a blink of an eye. Though we often start our programming journey with small example programs like - 

Find minimum or maximum from given any two or three values.

Swap two values etc. 

Having two or three variables may suffice in the above cases but for a large number of values, it is simply not possible. Arrays serve this purpose efficiently.

 

Types of Arrays

We can categorize into two

One-dimensional array – sequence of finite homogeneous elements.

Multi-dimensional array – each element is an array of elements of a similar type. Here we discuss only two and three-dimensional arrays.

 

Properties of an array

 

One-dimensional array

  • Arrays are contiguous memory locations of homogeneous elements denoted by arrayName[lower bound L, upper bound U] or arrayName[size](like in C++ or in Java). size = number of elements array named arrayName can hold and lower bound is 0 and upper bound is (size - 1) in case of programming implementation but theoretically lower bound can vary and so is upper bound to maintain the constraint upper bound – lower bound + 1 = size
  • Each value stored in an array is called an array element.
  •  

 

In this site, we are providing some standard array programs. For any demand of new program please mail us. 

 

Enjoy all programs related to array:

1.  Find Maximum and Minimum from an array

2.  Kth Largest and Smallest Element

3.  2nd largest element from the array

4.  Find how many negative numbers are present in the array

5.  The elements of one array are copied to another array

6.  Delete an element from any position in array

7.  Frequency of each element in the Array

8.  Find out the unique elements from the Array

9.  Finds odd and even elements from the array and stored in two separate arrays

10.  Counts the number of odd and even elements separately from the array 

11.  Reverses the elements of an Array

12.  Marge two Array and store in the third Array

13.  Rotated the Array at left

14.  Rotated the Array right

15.  Sorted the array and then separate even and odd elements in different array

16.  Sort the number of strings in an array

17.  Check one given element of an array present more than n/2 times or not

18.  The sum of the elements of an Array is calculated using a pointer

19.  The union and intersection between the two given arrays