Skip to main content

Array

An array is a linear collection of finite number of homogeneous data elements that store in a successive memory locations.
Size of array 
In case start index zero.
size=Upper Bound-Lower Bound+1
In case start index one.
size=Upper Bound
TYPES OF ARRAY
One dimensional array
Two dimensional array
Multi dimensional array
ONE DIMENSIONAL ARRAY
One dimensional array is a  array in which each element of array refer by single or one subscript.
Example:-A[1],A(1)
TWO DIMENSIONAL ARRAY
Two dimensional array is array in which each element of array is refer by two subscript.Two dimensional array structure require to store data in a form of table.
Example:-A[1,2],A(1,2)
MULTI DIMENSIONAL ARRAY
Multidimensional array is array in which each element of array reffer by two or more subscript.
 Example:-A[1].......A[n];
LINEAR ARRAY
A linear array is a list of a finite number n of homogeneous data elements such that the elements of the array are stored in successive memory locations.
 Ex:-A[4].
Upper Bound is the largest index.                                 
Lower Bound is the smallest index.                            
Formula:-  Length=Upper Bound-Lower Bound+1
Let LA be a linear array in the memory of the computer.The element of linear array are stored in consecutive memory locations.The computer does not keep track of address of each element of array.It only keeps track of the base address of the array. We can find out the location of any element by using formula and example:
LOCATION(LA[k])=Base(LA)+W(K-LB)
LOCATION(LA[K]) is the location of the K element LA.
W is the number of bytes taken by one     element.
K is the K  element.
LB is the lower bound.
Example:-Location(A[3])=1000+2(3-1) :=1000+2(2):=1004
TWO DIMENSIONAL ARRAY
Two dimensional array is array in which each element of array is refer by two subscript.Two dimensional array structure require to store data in a form of table.Ex:-A[1,2],A(1,2)
A two-dimensional m*n array A is a collection of m.n data elements such that each element is specified by a pair of integers(j,k).
Example:-A[3][3];
REPRESENTATION OF TWO-DIMENSIONAL ARRAY IN MEMORY
Memory representation of a 2-D array is different from the linear array.Specifically,the programming language will store the array A either (1) column by column is called column-major order and(2) row by row,is called row-major order.Let  A[3][3].
ROW MAJOR ORDER
TO FIND ADDRESS
Formula:- LOCATION(A[J.k])=Base(A)+w[N(J-1)+(K-1)]
COLUMN MAJOR ORDER
TO FIND ADDRESS
Formula:- LOCATION(A[J,K])=Base(A)+w[M(K-1)+(J-1)]

Comments

Popular posts from this blog

Generation of Computers

Generation of Computers   – Computers were developed in different phases known as generations of computer. Depending upon the technologies used the development of electronic computers can be divided into five generations. 1.  First generation The duration lasted from 1946-1959 was based on  vacuum tubes . Because thousands of such bulbs were used, the computers were very large and generate a large amount of heat, causing many problems in temperature regulation.  Magnetic drums   were used for  memory  purpose and instruction and data was given through  punch cards . Computer were operated manually and instruction given in  machine language . E.g.   –   UNIVAC  (Universal automatic computer),  ENIAC  (Electronic Numerical Integrator And Calculator ) ,  Mark I  etc. Main Features  – 1.        Vacuum tube technology used 2.     ...

Input and Output devices

Input device Input device is a device through which data and instruction are entered into computer system. An input devices converts the data and instructions into binary form that computer can understand. This transformation is performed by “Input interface”.   The data entered through input device can be some text, some graphical image or symbol, sound etc, depending on the form of the raw data the various input devices are available. Basic Function Performed by Input unit of a computer system -   1. It accepts the instruction and data from the user. 2. It converts these instruction and data in computer acceptable form. 3. It supplies the converted instruction and data to the computer system for further processing. Some of the commonly input devices used are:- 1. Keyboard 2. Mouse 3. Joy stick 4. Track ball 5. Touch screen 6. Light Pen 7. Digitizer 8. Scanner 9. Speech Recognition Devices 1. Keyboard Keyboard is an input device for enteri...

Computer Memory

Memory :  A memory is just like a human brain. It is used to store data and instructions. Computer memory is the storage space in computer where data is to be processed and instructions required for processing are stored. The memory is divided into large number of small parts. Each part is called cell. Each location or cell has a unique address, which varies from zero to memory size minus one. The computer storage memory is measure in term of Bytes. Eight bits make one Bytes. (Measure units)   Primary Memory/Main Memory Primary memory holds only those data and instructions on which computer is currently working. Has limited capacity and data gets lost when power is switched off. It is also called main memory. It is generally made up of semiconductor device. These memories are not as fast as registers. The data and instructions required to be processed earlier reside in main memory. Characteristic of Main Memory ·         ...