Resources » Articles/Knowledge Sharing » Computer & Technology

Array concept in data structure and its types


Posted Date: 24-May-2011  Last Updated:   Category: Computer & Technology    
Author: Member Level: Gold    Points: 10


Arrays are fixed size linear data structures in which the elements are accessed by indicating its index value. The index value of the starting element of an array will be 0 and arrays are used in high level programming languages. This article explains about the concept of arrays in the data sturucture and its types.



Array


An array is a data structure with same data type that contains a series of elements. The elements of an array can be identified by using its index value. The index value of the starting element of an array will be 0. So if we declare an array of size 5, then the index value of the elements in an array will be from 0 to 4 making 5 elements in that particular array. The concept of array is used in all the programming languages like C, C++, and JAVA. The data structure concepts like stack and queue implements array to represent them.

Syntax:
Let us now see the syntax for using an array:
Array Declaration: Datatype array_name [size]

Array Initialization: Datatype array_name [size] = {value1, value2…Value n};

Example:
Int A [5];

Int A [3] = {100, 1000, 10000};

Where Int – is the data type of Integer
A [5] – Array A of size 5
A [3] – Array A of size 3

Types of Array:



The following are the different types of Array used:
  • One-dimensional array
  • Two-dimensional array (Multi-dimensional array)

    One-dimensional array:
    One-dimensional array is also called as single dimension array and it will be of a linear type (Elements will be accessed in sequential order). This type of array will be accessed by the subscript of either a column or row index.

    Two-dimensional array:
    Two-dimensional array will be accessed by using the subscript of row and column index. For traversing the two-dimensional array the value of the rows and columns will be considered. The following example represents the two-dimensional array.

    Int table = A [10] [20]

    The above access the two-dimensional array of row value 10 and the column value 20. So the table will be accessible with 10 rows and 20 columns.

    Important concept of array:


  • Array always fixed size of data elements (Declaration)
  • Array can be considered as a static data
  • Array elements are placed in sequential order thus eliminating the gap in the memory allocation
  • The index value starts with 0
  • The data elements should be of same data type
  • Array can be used in search algorithms (Binary search)
  • Array can be used in sorting algorithms (Bubble sort)
  • An array can be declared, initialized and referred by value.


  • Did you like this resource? Share it with your friends and show your love!




    Responses to "Array concept in data structure and its types"

    No responses found. Be the first to respond...

    Feedbacks      

    Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.