Consider the linear arrays XXX (-10:10), YYY (1935:1985), ZZZ (35).
(a) Find the number of element in each array.
(b) Suppose Base (YYY) = 400 and w=4 words per memory cell for YYY. Find the address of YYY [1942], YYY [1977] and YYY [1988].
Answer:
(a) Given Linear arrays are: XXX (-10:10), YYY(1935:1985) and ZZZ(35)
The number of elements is equal to the length. We can determine the length
By the following formula,
Length = UB – LB +1
For XXX the Upper Bound is 10 and the Lower Bound is -10
For YYY the Upper Bound is 1985 and the Lower Bound is 1935 and
For ZZZ the Upper Bound is 35 and Lower Bound is 1.
So,
Length (XXX) = UB (XXX) – LB (XXX) +1
= 10 – (-10) + 1
= 21
Then,
Length (YYY) = UB (YYY) – LB (YYY) +1
= 1985 – 1935 +1
= 51
And, Length (ZZZ) = UB (ZZZ) – LB (ZZZ) +1
= 35 – 1 +1
=35
(b) We know,
Address of any element of a linear array LA is determined by the formula,
LOC (LA[k]) = Base (LA) + w (k – lower bound)
Where,
Base (LA) = Base address of linear array LA.
w = Number of words per memory cell for the array LA
And k = Any elements of linear array LA
Given,
Base (YYY) = 400,
Lower Bound = 1935
And w = 4
SO, LOC (YYY [1942]) = 400 + 4(1942 – 1935)
= 428
LOC (YYY [1977]) = 400 + 4(1977 – 1935)
= 568
LOC (YYY [1988]) = 400 + 4(1988 – 1935)
= 612
Hello there, I found your blog by means of Google while looking for a comparable matter, your web site got here up, it appears great. I’ve bookmarked it in my google bookmarks.
I couldn’t refrain from commenting. Well written!|
I am sure this article has touched all the internet visitors, its really really nice piece of writing on building up new website.|
Can I simply say what a comfort to discover somebody who truly understands what they are talking about on the internet. You actually understand how to bring an issue to light and make it important. More and more people must check this out and understand this side of the story. It’s surprising you are not more popular since you most certainly have the gift.|
First of all I would like to say terrific blog! I had a quick question which I’d like to ask if you don’t mind. I was interested to know how you center yourself and clear your thoughts prior to writing. I’ve had a hard time clearing my mind in getting my ideas out there. I truly do enjoy writing but it just seems like the first 10 to 15 minutes tend to be lost just trying to figure out how to begin. Any recommendations or tips? Many thanks!|