What is Array?

For Easy Understand You Should Also check Video of this topic

Introduction

                 The simplest form of array may be defined abstractly as a finite ordered set of homogeneous elements. By “finite” we mean that there is a specific number of elements in the array this number may be large or small, but it must exist. By “ordered” we mean that the elements of the array are arranged so that there is a zeroth, first, second, third, and so forth. By “homogeneous” we mean that all the elements in the array must be of the same type.

For example, an array may contain all integers or all characters but may not contain both.

Fundamental Syntax <Data_type> <Array_name> [size];  
Declaration of Array  Int number [3];   char data[5];
Initialization of array          1-way                                                        2-way
int number[3] = { 9, 5, 2 };   number[0] =9; number[1] =7; number[2] =5;  
char data[3]={‘a’,’b’,’c’};
Types of Array Accordingly structure of memory          
arrays are two types        1st One Dimension Array and Multi Dimension Array.
Array how to organize in memory
Array index  Elements    Addresses  
-LB- X[0]1 000000010x0000
X[1]2  000000100x0001
X[2]3  000000110x0002
X[3]4  000001000x0003
X[4]5  000001010x0004
X[5]6  000001100x0005
X[6]7  000001110x0006
  …   … .   …      . … … …..  ………..…
X[127]127 011111110X000..
Array index start from zero because memory addresses are start from zero.    Total number of element can be present in array X[size] is depends on the size of the data type which is totally depends on compiler and operating system.   The range of the value is depends on the type and size of variable.   The size of memory address is also depends on the type and size of the elements.   1 Byte value range  is 8 bit 28-1 address means  -128 to 127    00000000 ->0  00000001 ->127    .  01111111 ->127   10000000 ->128 .                                   -128 -> 11111111     total -> 255 .

    Basic problems on array .
*Length of the array?
*Finding address of particular array index.
*What should be the time complexity?

                                  

error: Content is protected !!
Open chat
1
Hi,how Can We Help You ?