Page 407 - CA_Blue( J )_Class10
P. 407
5 10 15 2 9 14
Write a program to assign the above Matrixes and print the result as Sum of left diagonal of array A/Sum of right diagonal of array B.
21. Write a program to accept numbers in an array of size 2 x 3. Calculate and display the even numbers row-wise.
Example:
A[][]= 12 23 36 48
54 11 15 35
11 22 43 24
Output: 12 36 48
54
22 24
22. Write a program using 2d Array to generate a Pascal triangle in which each number in the row is the sum of the two numbers
immediately above it. The program should accept the number of rows and print the following:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
23. Write a program to accept numbers in an array of size 4 x 4. Display the largest number column-wise.
C. Assertion and Reasoning based questions.
The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting the
appropriate option given below:
a. Both A and R are true, and R is the correct explanation of A.
b. Both A and R are true, but R is not the correct explanation of A.
c. A is true, but R is false.
d. A is false, but R is true.
1. Assertion (A): Selection sort is suitable for sorting one-dimensional arrays in Java.
Reason (R): Selection sort is a simple sorting algorithm that repeatedly selects the minimum element from the unsorted portion
of the array and places it at the middle of the array length.
2. Assertion (A): Binary search is an efficient algorithm for finding an element in a sorted one-dimensional array in Java.
Reason (R): Binary search works by repeatedly dividing the search interval in half. If the value of the search key is less than the
item in the middle of the interval, it narrows the interval to the lower half. Otherwise, it narrows it to the upper half. This process
continues until the value is found or the interval is empty.
Previous Years' Questions
SECTION A
1. What is the difference between the linear search and the binary search technique? [2019]
Ans.
Linear Search Binary Search
Array elements may or may not be in sorted order. Array elements should be in sorted order.
Execution is slow. Execution is fast.
Searching begins from the first element and proceeds Search begins from the middle element and proceeds either to the left
to the last. or to the right depending on the value of the searched element.
2. String x[] = {"Artificial intelligence", "IOT", "Machine Learning", "Big data"};
Give the output of the following statements:
(i) System.out.println(x[3]); (ii) System.out.println(x.length); [2019
405
Arrays 405

