Initializing Matrix Data Structure
In initialization, we assign some initial value to all the cells of the matrix. Below is the implementation to initialize a matrix in different languages:
#include <iostream>
using namespace std;
int main() {
// Initializing a 2-D array with values
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
return 0;
}
#include <stdio.h>
int main() {
// Initializing a 2-D array with values
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
return 0;
}
/*package whatever //do not write package name here */
import java.io.*;
class GFG {
public static void main(String[] args)
{
// Initializing a 2-D array with values
int arr[][]
= { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
}
}
# Initializing a 2-D array with values
arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
using System;
public class GFG {
static public void Main()
{
int[, ] arr = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
}
}
// Initializing a 2-D array with values
let arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
Introduction to Matrix or Grid Data Structure – Two Dimensional Array
Matrix or Grid is a two-dimensional array mostly used in mathematical and scientific calculations. It is also considered as an array of arrays, where array at each index has the same size. In this article, we will cover all the basics of Matrix, the Operations on Matrix, its implementation, advantages, disadvantages which will help you solve all the problems based on Matrix Data Structure.
Table of Content
- What is a Matrix Data Structure?
- Representation of Matrix Data Structure
- Declaration of Matrix Data Structure
- Initializing Matrix Data Structure
- Operations on Matrix Data Structure
- Access elements of Matrix Data Structure
- Traversal of a Matrix Data Structure
- Searching in a Matrix Data Structure
- Sorting Matrix Data Structure
- Applications of Matrix Data Structure
- Advantages of Matrix Data Structure
- Disadvantages of Matrix Data Structure
- More Practice problems on Matrix Data Structure
Contact Us