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

The quick sort algorithm exploit design technique, The quick sort algorithm...

The quick sort algorithm exploit design technique Divide and Conquer

The various ways in which lc code can be accessed, Problem Your LC code...

Problem Your LC code is stored in a memory location as shown and the variable name is LC                  LC Memory address       Content(LC code)

Sorting algorithms, Sorting is significant application activity. Several so...

Sorting is significant application activity. Several sorting algorithms are obtainable. But, each is efficient for a specific situation or a specific kind of data. The choice of a

Explain decision tree, Decision Tree A decision tree is a diagram that ...

Decision Tree A decision tree is a diagram that shows conditions and actions sequentially and therefore shows which condition is to be considered first, second and so on. It is

Graphs, floyd warshall algorithm

floyd warshall algorithm

Define prims algorithm, Define Prim's Algorithm Prim's  algorithm  is  ...

Define Prim's Algorithm Prim's  algorithm  is  a  greedy  algorithm  for  constructing  a  minimum  spanning  tree  of  a  weighted linked graph. It works by attaching to a bef

Define the terms - key attribute and value set, Define the terms   ...

Define the terms     i) Key attribute     ii) Value set  Key attribute:  An entity  type  usually  has  an attribute  whose  values  are  distinct  fr

Explain time complexity, Time Complexity, Big O notation The amount of ...

Time Complexity, Big O notation The amount of time needed by an algorithm to run to its completion is referred as time complexity. The asymptotic running time of an algorithm i

Total impedent of the circuit, an electrical student designed a circuit in...

an electrical student designed a circuit in which the impedence in one part of a series circuit is 2+j8 ohms and the impedent is another part of the circuit is 4-j60 ohm mm program

Several operations on a aa-tree, The following are several operations on a ...

The following are several operations on a AA-tree: 1. Searching: Searching is done using an algorithm which is similar to the search algorithm of a binary search tree. 2. Ins

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