In-Place Matrix Rotation: Clockwise 90-Degree Transformation

Problem Statement Given an n × n 2D matrix representing an image, rotate the image clockwise by 90 degrees. The rotation must be performed in-place without using an auxiliary matrix. Algorithm Approach The clockwise rotation can be achieved through two sequential operations: Transpose along the main diagonal — swap rows and columns Mirror each ...

Posted on Wed, 24 Jun 2026 16:52:12 +0000 by littledragon

In-Place Heap Sort Using Max-Heap Adjustments

Replacing the Linear Scan in Selection Sort Traditional selection sort repeatedyl picks the smallest element from the unsorted suffix and swaps it forward. The bottleneck is the linear scan that finds that minimum, giving an overall Θ(n²) runtime. static void naiveSelection(int[] a) { for (int i = 0; i < a.length - 1; i++) { int ...

Posted on Wed, 20 May 2026 07:03:31 +0000 by jynmeyer