Sei sulla pagina 1di 2

WORKSHEET (2D Arrays)

1. Write a pseudocode to input values in a 2D array of size [5][5]. The pseudocode then should
print the saddle point of the array which is an element smallest in its row and largest in the
same column. For example in the following array element at [3][0] is the saddle point of the
array –

11 16 57 39 22

18 39 51 24 81

14 26 13 23 21

21 41 32 26 24

20 45 12 81 28

Please note that it is possible that an array may not have a saddle point in it.
2. Input numbers in a 2D array of size [r][c]. Print this array. The pseudocode then transpose
this array and then print the transposed array. For example the following array of size [2][3]
should be transposed to an array of size [3][2] –
1 6 7 1 2

2 3 5 6 3

7 5

3. Write a pseudocode to input values in a 2D array whose number of columns are always even.
The pseudocode should then swap the elements of every odd column to the even column.
You must implement this pseudocode to a Java code and execute it to test the logic and
functionality.
Original Changed
6 1 9 7
1 6 7 9
3 2 4 5
2 3 5 4
4 4 2 3
4 4 3 2
4 2 6 3
2 4 3 6

Page 1 of 2
4. Assume two arrays ‘A’ and ‘B’ of sizes ‘x’ and ‘y’. Array ‘A’ stores element in ascending
order whereas array ‘B’ stores elements in descending order. Write a pseudocode to merge
these two arrays into a 3rd array ‘C’ of size x+y or may be less assuming there might be
duplicate elements in both the array. The 3rd array ‘C’ should be in ascending order. Your
program should not use any sorting algorithm on any of the array assuming the user will
enter values in desired order in array ‘A’ and ‘B’. For example have a look of following –
Array A 
1 2 3 4 5 6

Array B 
12 9 8 7 6

Array C 
1 2 3 4 5 6 7 8 9 12

Page 2 of 2

Potrebbero piacerti anche