Calculate address of an element in an array., Data Structure & Algorithms

Q. Explain the technique to calculate the address of an element in an array. A 25 × 4 matrix array DATA is stored in memory in 'row-major order'. If base address is 200 and ω = 4 words per memory of the cell.  Calculate the DATA address [12, 3]                                                                                     

Ans:

In a row major representation, address of any element a[i][j] can be found using the formula written below: a[i][j]=base(a)+(i*m+j)*size where base(a) is base address, m is the number of columns and size represent size of word.

DATA[12,3]=200+(12*4+3)*4

=200+(48+3)*4

=200+51*4

=200+204

=404 

 

 

 

 

Posted Date: 7/10/2012 5:21:13 AM | Location : United States







Related Discussions:- Calculate address of an element in an array., Assignment Help, Ask Question on Calculate address of an element in an array., Get Answer, Expert's Help, Calculate address of an element in an array. Discussions

Write discussion on Calculate address of an element in an array.
Your posts are moderated
Related Questions
What is the time complexity of Merge sort and Heap sort algorithms? Time complexity of merge sort is O(N log2 N) Time complexity of heap sort is   O(nlog2n)

Write the non-recursive algorithm to traverse a tree in preorder.    The Non- Recursive algorithm for preorder traversal is as follows: Initially  push NULL onto stack and

Q. Take an array A[20, 10] of your own. Suppose 4 words per memory cell and the base address of array A is 100. Find the address of A[11, 5] supposed row major storage.

Define Dynamic Programming  Dynamic  programming  is  a  method  for  solving  problems  with  overlapping  problems.  Typically, these sub problems arise from a recurrence rel

Warnock's Algorithm A divide and conquer algorithm Warnock (PolyList PL, ViewPort VP) If (PL simple in VP) then Draw PL in VP, else Split VP vertically and horiz

Data type An implementation of an abstract data type on a computer. Therefore, for instance, Boolean ADT is implemented as the Boolean type in Java, and bool type in C++;

Mid Square method with good example

A full binary tree with 2n+1 nodes have n non-leaf nodes

Define Spanning Tree A Spanning Tree of a connected graph is its linked acyclic sub graph (i.e., a tree) that having all the vertices of the graph.