Skip to main content
BharatBoard

Last verified: 28 November 2026 across official school board and government recruitment portals.

BharatBoard is a private, independent guide. It does not represent any government entity and does not provide any government service. Information is summarised from official board and government websites.

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 a of length n): Outer loop for (int i = 0; i < n - 1; i++) and inner loop for (int j = 0; j < n - 1 - i; j++); if a[j] > a[j + 1], swap a[j] and a[j + 1] using a temporary variable t. (For Strings, use if (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 0 to N - 1: an element m[r][c] lies on the Left (Principal) Diagonal when r == c, and lies on the Right (Secondary) Diagonal when r + 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.