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
The controversy of RISC versus CISC never ends. Suppose that you represent an advocate for the RISC approach; write at least a one-page critic of the CISC approach showing its disa

One of the main problems with the linear queue is the lack of appropriate utilization of space. Assume that the queue can store 100 elements & the complete queue is full. Thus, it

Q. What do you understand by the term Binary Tree? What is the maximum number of nodes which are possible in a Binary Tree of depth d. Explain the terms given below with respect to

using a program flowchart design a program to illustrate pop and push operation

What is Assertions Introduction At every point in a program, there are generally constraints on the computational state that should hold for program to be correct. For ins

What is an Algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for getting a needed output for any legitimate input in a finite amoun

differences between direct and indirect recursion

Complexity : How do the resource needs of a program or algorithm scale (the growth of resource requirements as a function of input). In other words, what happens with the performan

Q .  Write down the non-recursive algorithm to traverse a tree in preorder. Ans: T he Non- Recursive algorithm for preorder traversal is written below: Initially i

The time required to delete a node x from a doubly linked list having n nodes is O (1)