0% found this document useful (0 votes)
95 views3 pages

Arrays - DPP 01

The document contains a Data Structure and Programming assignment focused on arrays, including both 1D and 2D arrays. It presents various problems related to calculating addresses and elements in arrays, along with an answer key and hints for solutions. Additionally, it provides links for reporting issues and accessing more resources.

Uploaded by

nogak99812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views3 pages

Arrays - DPP 01

The document contains a Data Structure and Programming assignment focused on arrays, including both 1D and 2D arrays. It presents various problems related to calculating addresses and elements in arrays, along with an answer key and hints for solutions. Additionally, it provides links for reporting issues and accessing more resources.

Uploaded by

nogak99812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1

BRANCH:CSE/IT Batch-Hinglish
Data structure & Programming
Arrays DPP-01

[NAT] [NAT]
1. Consider a 1D array a with 9 elements. If the base 8. Consider a 2D array arr[-15 to 15][-7 to 7]. Find the
address of the array is 108 and the size of each array address of the location arr[-1][5] if the starting address
element is 4 bytes, the address of a[7] is- ________ of the array is 500 and size of each element is 4 bytes.
(Assume array index starts from 0) (Suppose, the elements are stored in column-major
order) _______________
[NAT]
2.
Consider a 1D array a[-127…………..,+255] where -127
and +255 are the starting index and ending index of the
array respectively. The number of elements in the array is
____________.

[NAT]
3. Consider a 1D array a with 19 elements. If the base
address of the array is 108 and the size of each array
element is 4 bytes, the address of a[7] is-
(Assume array index starts from -11)____________

[NAT]
4. Consider a 2D array a[-127 to +255][-13 to +14]. The
number of elements in the array is ____________.

[NAT]
5. Consider the natural numbers from 1 to 256 are stored
in a 2D array arr[-28 to 3][-3 to 3]. Find the element
present at location arr[-16][1]. (Suppose, the elements
are stored in row-major order)_______________

[NAT]
6. Consider the natural numbers from 1 to 256 are stored
in a 2D array arr[-28 to 3][-3 to 3]. Find the address of
the location arr[-16][1] if the starting address of the
array is 625 and size of each element is 4 bytes.
(Suppose, the elements are stored in row-major order)
________________.
[NAT]
7. Consider the whole numbers from 0 to 127 are stored
in a 2D array arr[0 to 15][0 to 7]. Find the element
present at location arr[6][4]. (Suppose, the elements
are stored in column-major order)___________
2

Answer Key
1. (136) 5. (89)
2. (383) 6. (977)
3. (180) 7. (70)
4. (10724) 8. (2044)
3

Hints and Solutions

1. (136) 6. (977)
Address of a[7] = 108+(7-0)*4 = 136. Number of elements in each column= 3-(-3)+1=7
Address of location arr[-16][1]
2. (383) = 625 + [(-16-(-28))*7+(1-(-3))]*4
Number of elements in the array=255-(-127)+1=383 = 977
3. (180) 7. (70)
Address of a[7] = 108+(7-(-11))*4 = 180. Number of elements in each row= 16
4. (10724) The element present at arr[6][4]=(4-0)*16+(6-0)=70
Number of elements in each row= 255-(-127)+1=383 8. (2044)
Number of elements in each column = +14-(-13)+1=28 Number of elements in each row= 15-(-15)+1=31
Number of elements in the 2D array = 383*28 = 10724 Address of location arr[-1][5]
5. (89) = 500 + [(5-(-7))*31+(-1-(-15))]*4
= 2044
Number of elements in each column=3-(-3)+1=7
The element present at arr[-16][1]
=(-16-(-28))*7+(1-(-3)+1)
=89.

Any issue with DPP, please report by clicking here:- https://forms.gle/t2SzQVvQcs638c4r5


For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if

PW Mobile APP: https://smart.link/7wwosivoicgd4

You might also like