Arrays
75 programs in this topic — each includes source code, sample output and explanation.
-
Array Initialization and Traversal
This program demonstrates initialization and traversal of a single dimensional array.
-
Array Sum Calculation
This program calculates the sum of elements in an array.
-
Array Maximum Element
This program finds the maximum element in an array.
-
Array Reverse Traversal
This program prints array elements in reverse order.
-
Array Average Calculation
This program calculates the average of array elements.
-
Linear Search in Array
This program performs linear search to find an element in an array.
-
Binary Search in Array
This program performs binary search to find an element in a sorted array.
-
Bubble Sort Implementation
This program sorts an array using bubble sort algorithm.
-
Selection Sort Implementation
This program sorts an array using selection sort algorithm.
-
Insertion Sort Implementation
This program sorts an array using insertion sort algorithm.
-
Copy Elements of Array
This program copies elements from one array to another.
-
Merge Two Arrays
This program merges two arrays into one.
-
Insert Element in Array
This program inserts an element at a specific position in an array.
-
Delete Element from Array
This program deletes an element from a specific position in an array.
-
Rotate Array Elements
This program rotates array elements to the left by 2 positions.
-
Matrix Initialization and Display
This program initializes and displays a 3x3 matrix.
-
Addition of Two Matrices
This program adds two matrices element wise.
-
Subtraction of Two Matrices
This program subtracts one matrix from another element wise.
-
Multiplication of Two Matrices
This program multiplies two matrices.
-
Transpose of Matrix
This program finds the transpose of a matrix.
-
Sum of Main Diagonal Elements
This program calculates the sum of main diagonal elements of a matrix.
-
Sum of Secondary Diagonal Elements
This program calculates the sum of secondary diagonal elements of a matrix.
-
Row Sum of Matrix
This program calculates the sum of each row in a matrix.
-
Column Sum of Matrix
This program calculates the sum of each column in a matrix.
-
Identity Matrix Check
This program checks if a matrix is an identity matrix.
-
Symmetric Matrix Check
This program checks if a matrix is symmetric.
-
Sparse Matrix Check
This program checks if a matrix is sparse.
-
Boundary Elements of Matrix
This program prints boundary elements of a matrix.
-
Rotate Matrix 90 Degrees
This program rotates a matrix by 90 degrees clockwise.
-
Rotate Matrix 180 Degrees
This program rotates a matrix by 180 degrees.
-
Rotate Matrix 270 Degrees
This program rotates a matrix by 270 degrees clockwise (or 90 degrees counter clockwise).
-
Symmetric Matrix Extended Check
This program checks if a matrix is symmetric and prints mismatched positions.
-
Sparse Matrix Representation
This program represents a sparse matrix using triplet form.
-
Boundary Sum of Matrix
This program calculates the sum of boundary elements of a matrix.
-
Spiral Traversal of Matrix
This program prints elements of a matrix in spiral order.
-
Linear Search with Early Exit
This program performs linear search with early exit optimization.
-
Recursive Binary Search
This program performs binary search using recursion.
-
Print Both Diagonals of Matrix
This program prints both main and secondary diagonals of a matrix.
-
Jagged Array Initialization
This program initializes and displays a jagged array.
-
Jagged Array Traversal
This program traverses a jagged array and prints elements with indices.
-
Frequency of Elements in Array
This program calculates frequency of each element in an array.
-
Frequency of Characters in Array
This program calculates frequency of characters in a character array.
-
Find Most Frequent Element
This program finds the most frequent element in an array.
-
Find Least Frequent Element
This program finds the least frequent element in an array.
-
Frequency Distribution of Array
This program prints frequency distribution of elements in an array.
-
Prefix Sum of Array
This program calculates prefix sums of an array.
-
Maximum Subarray Sum (Kadane's Algorithm)
This program finds maximum subarray sum using Kadane's algorithm.
-
Subarray with Given Sum
This program finds subarray with a given sum.
-
Boundary Traversal of Matrix
This program prints boundary traversal of a matrix.
-
Check Rotated Matrix Equality
This program checks if one matrix is rotation of another.
-
Range Sum Query using Prefix Sum
This program answers range sum queries using prefix sums.
-
Maximum Length Subarray with Given Sum
This program finds maximum length subarray with sum equal to target.
-
Spiral Traversal Extended
This program prints elements of a 4x4 matrix in spiral order.
-
Check Rotated Matrix Equality (180 Degrees)
This program checks if one matrix is rotation of another by 180 degrees.
-
Check Rotated Matrix Equality (270 Degrees)
This program checks if one matrix is rotation of another by 270 degrees.
-
Partition Array into Even and Odd
This program partitions an array into even and odd numbers.
-
Partition Array Around Pivot
This program partitions an array around a pivot element.
-
Find Equilibrium Index
This program finds equilibrium index of an array.
-
Boundary Diagonals of Matrix
This program prints boundary diagonals of a matrix.
-
Maximum Sum Subarray of Size K
This program finds maximum sum subarray of size K using sliding window.
-
Subarray with Given Sum using Two Pointers
This program finds subarray with given sum using two pointers.
-
Count Subarrays with Given Sum
This program counts the number of subarrays with a given sum.
-
Maximum Circular Subarray Sum
This program finds maximum circular subarray sum.
-
Sum of Boundary Diagonals
This program calculates sum of both diagonals of a matrix.
-
Longest Subarray with Equal 0s and 1s
This program finds longest subarray with equal number of 0s and 1s.
-
Optimized In Place Transpose of Square Matrix
This program performs in place transpose of a square matrix without using extra space.
-
Rotated Spiral Traversal
This program prints matrix elements in spiral order starting from bottom left corner.
-
Sparse Matrix Compression (Triplet Form)
This program compresses sparse matrix into triplet form.
-
Maximum Product Subarray
This program finds maximum product subarray.
-
Subarray Product Less Than K
This program counts subarrays with product less than K.
-
Transpose and Rotate Matrix
This program transposes a matrix and then rotates it by 90 degrees.
-
Reverse Spiral Traversal
This program prints matrix elements in reverse spiral order.
-
Sparse Matrix Compression (Row Wise)
This program compresses sparse matrix row wise.
-
Subarray Product Equals Target
This program finds subarray with product equal to target.
-
Maximum Product of Subarray of Size K
This program finds maximum product of subarray of fixed size K.