Arrays and Matrix Operations in C

Exercise 1: Array Memory Layout This program demonstrates memory allocation patterns for one-dimensional and two-dimensional arrays: #include <stdio.h> #define ROWS 4 #define COLS 2 void show_1d_layout() { int vector[ROWS] = { 10, 20, 30, 40 }; printf("Vector size: %d bytes\n", sizeof(vector)); for (int i = 0; ...

Posted on Fri, 15 May 2026 21:24:11 +0000 by symantec

Efficient In-Place Matrix Zeroing Using First Row and Column Markers

Given an m x n matrix, if an element is zero, set its entire row and column to zero. The challenge is to perform this modification in place without using extra matrix storage. The key idea: use the first row and first column as flag storage to record which rows and columns need zeroing, then apply the changes in a final pass. Algorithm Outline ...

Posted on Thu, 14 May 2026 01:15:41 +0000 by Muntjewerf

Minimum Path Sum in a Grid Using Dynamic Programming

Given a grid of non-negative integers, find the path from the top-left corner to the bottom-right corner that miniimzes the sum of the values along the path. Movement is restricted to only down or right directions. Example 1: Input: [[1,3,1],[1,5,1],[4,2,1]] Output: 7 Explanation: The path 1→3→1→1→1 yields the minimum sum. Example 2: Input: [[1 ...

Posted on Sun, 10 May 2026 08:09:15 +0000 by tcl4p