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
WOW just what I was searching for. Came here by searching for meta_keyword|
Its very awesome article,all the content is so beneficial and valuable for us.presentation of article is very good,so I will bookmark it for sharing it with my friends.Thanks for sharing nice and pretty post.
Attractive element of content. I just stumbled upon your blog and in accession capital to claim that I get actually enjoyed account your weblog posts. Any way I’ll be subscribing in your feeds and even I achievement you get right of entry to consistently quickly.|
Woah! I’m really enjoying the template/theme of this blog. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between user friendliness and visual appearance. I must say you have done a awesome job with this. Additionally, the blog loads extremely quick for me on Opera. Superb Blog!|
Hi there, I enjoy reading all of your article post. I wanted to write a little comment to support you.|