Array vs. ordinary variable, Data Structure & Algorithms

Assignment Help:

Q. Describe what do you understand by the term array? How does an array vary from an ordinary variable? How are the arrays represented in the specific memory?                                    

Ans.

Array Vs. Ordinary Variable is explained as follows

Array is made from the similar data structure that exists in any language. Array is the set of similar or alike data types. Array is the collection of similar or alike elements. These similar or alike elements could be all int or all float or all char etc. Array of char is called as string. All elements of the given array should be of same type. An array is finite ordered set of the homogeneous elements. The number of elements in the array is pre- determined.

For example.  Ordinary variable: - int a

Array:      -      int a[10]

An ordinary variable of a simple data type can save a single element only

Representation of Array in memory is shown below

Assume a be a 2 dimensional m x n array

 

 

Col 0

Col 1

Col 2

 

Row 0

 

a00

 

a01

 

a02

 

Row 1

 

a10

 

a11

 

a12

 

Row 2

 

a20

 

a21

 

a22

 

Though  a  is  pictured  as  a  rectangular pattern  with  in  row  and  n  column  it  is represented in memory or a particular location by a row of m x n  elements. Sequential memory locations the element can be saved in row major order.

Column major order is explained as follows:- the elements are saved column by column i.e. m elements of the 1st column is saved in first m locations, elements of the 2nd column are saved in next m location and so on..

1545_column major.png

Row major order is shown below:-

The elements are saved row by row ie. N elements of the 1st row are saved in 1st n location, elements of 2nd row are saved in next n location, and so on

1808_row major.png


Related Discussions:- Array vs. ordinary variable

Define big oh notation, Big oh notation (O) : The upper bound for the funct...

Big oh notation (O) : The upper bound for the function 'f' is given by the big oh notation (O). Considering 'g' to be a function from the non-negative integers to the positive real

State about the simple types - built-in types, State about the Simple types...

State about the Simple types - Built-In Types Values of the carrier set are atomic, that is, they can't be divided into parts. Common illustrations of simple types are inte

Functions and modelling the data flows, Read the scenario (Pickerings Prope...

Read the scenario (Pickerings Properties). (a) List the functions of the system, as perceived by an external user. (b) List the external entities. Note that because we are mo

Calculate the k-th power and recursive algorithem, 1. The following is a r...

1. The following is a recursive algorithm to calculate the k -th power of 2. Input k a natural number Output kth power of 2 Algorithem: If k =0then return 1 Else return 2* po

Programs, Develop a program that accepts the car registration( hint: LEA 43...

Develop a program that accepts the car registration( hint: LEA 43242010)

Analyze an algorithm, In order to analyze an algorithm is to find out the a...

In order to analyze an algorithm is to find out the amount of resources (like time & storage) that are utilized to execute. Mostly algorithms are designed to work along with inputs

Use of asymptotic notation in the study of algorithm, Q. What is the need o...

Q. What is the need of using asymptotic notation in the study of algorithm? Describe the commonly used asymptotic notations and also give their significance.

Efficient way of storing a sparse matrix in memory, Explain an efficient wa...

Explain an efficient way of storing a sparse matrix in memory.   A matrix in which number of zero entries are much higher than the number of non zero entries is called sparse mat

Tower of hanoi, how do we use 4-discs stack to solve tower of hanoi problem...

how do we use 4-discs stack to solve tower of hanoi problem and write an algorithm to solve it?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd