CISCE (ICSE/ISC) · Guide
ICSE Class 10 Java Part 2: 1D & 2D Arrays, Bubble/Selection Sort & Linear/Binary Search
Ready-to-write Java logic for ICSE Class 10 Computer Applications (Code 86) Section B — Linear Search, Binary Search (on sorted arrays), Bubble Sort, Selection Sort, and 2D Matrix row/column/diagonal sums.
Reviewed July 2026
Bubble Sort vs Selection Sort and Linear Search vs Binary Search in Java
At least one and often two 15-mark questions in ICSE Computer Applications Section B test 1D Array searching/sorting and 2D Array matrix operations.
- Bubble Sort (Ascending order on array
aof lengthn): Outer loopfor (int i = 0; i < n - 1; i++)and inner loopfor (int j = 0; j < n - 1 - i; j++); ifa[j] > a[j + 1], swapa[j]anda[j + 1]using a temporary variablet. (For Strings, useif (a[j].compareTo(a[j + 1]) > 0)). - Selection Sort (Ascending order): Outer loop
for (int i = 0; i < n - 1; i++) { int min = i; for (int j = i + 1; j < n; j++) { if (a[j] < a[min]) min = j; } int t = a[i]; a[i] = a[min]; a[min] = t; }. - Binary Search (Requires a pre-sorted array!): Set
int low = 0, high = n - 1, pos = -1; while (low <= high) { int mid = (low + high) / 2; if (a[mid] == key) { pos = mid; break; } else if (key > a[mid]) low = mid + 1; else high = mid - 1; }(Reverse the</>check if the given array is sorted in descending order!).
2D Matrix (int m[][] = new int[4][4]) Left vs Right Diagonal index formulas
- For an N × N square matrix indexed from
0toN - 1: an elementm[r][c]lies on the Left (Principal) Diagonal whenr == c, and lies on the Right (Secondary) Diagonal whenr + c == N - 1(so for a 4 × 4 matrix,r + c == 3). - Don’t forget the mandatory Variable Description Table (VDT) (3 columns: Variable Name, Data Type, Purpose) at the end of every Section B Java program to secure the final 2–3 marks!
Official sources
Timing is typical months only — always verify the exact dates on the official board website, which change every session.