For the following snippet of code, ?? and ?? are integer variables and the varia
ID: 3901888 • Letter: F
Question
For the following snippet of code, ?? and ?? are integer variables and the variable A is a two-dimensional array with 10 rows (index 0 to 9) and 20 columns (index 0 to 19) ?????? ??=0 ???? 9 ?????? ??=0 ???? 19 ??[??][??]=3???+??
Write the following statements as logical formulae
a. All entries of A are positive and less than or equal to 70
b. Each row of A contains at least one entry greater than 60
c. The entries in each column of A are sorted into strictly increasing order
d. The entries in the first three rows of A are distinct
Please help meee thanks!!!!!
Explanation / Answer
Entries in array are filled according to 3*n+m
a) Since both n and m are >=0 therfore entries are always positive.Maximum entry in array is obtained when both n and m are maximum.nmax = 19 and mmax = 9 hence maximum value is 3*19 + 9 =68 that is <=70.Therefore it is true
b) For each row,maimum value is obtained for maimum n that is for last column.
In 1st row,maximum value = 3*19+0=57 that is<60 hence given statement is false.
c) For each column,value of n is fixed and hence only m will be varying from 0 to 9 and that is increasing with the increase in row number hence given statement is true.
d) For the 1st row,entries are - 3*0+0,3*1+0,3*2+0,....,3*19+0 that is - 0,3,6,...,57
For the 2nd row,entries are - 3*0+1,3*1+1,3*2+1,....,3*19+1 that is - 1,4,7,...,58
For the 3rd row,entries are - 3*0+2,3*1+2,3*2+2,....,3*19+2 that is - 2,5,8,...,59
Clearly all values are of the form 3*n,3*n+1 and 3*n+2 hence all values are distinct and hence given statement is true.
Hope i have answered your question satisfactorily.Leave doubts in comment section if any.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.