{"id":84189,"date":"2021-09-21T09:00:34","date_gmt":"2021-09-21T03:30:34","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=84189"},"modified":"2021-09-21T09:00:34","modified_gmt":"2021-09-21T03:30:34","slug":"sparse-matrix-in-data-structure","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/","title":{"rendered":"Sparse Matrix in Data Structure"},"content":{"rendered":"<p>In programming, we usually represent a 2-D array in the form of a matrix. However, if a matrix has most of its elements equal to zero, then the matrix is known as a sparse matrix. In the case of a sparse matrix, we don\u2019t store the zeros in the memory to reduce memory usage and make it more efficient. We only store the non-zero values of the sparse matrix inside the memory.<\/p>\n<p>For example, in the following 5*4 matrix, most of the numbers are zero. Only a few elements are non-zero which makes it a sparse matrix.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84895\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image01.jpg\" alt=\"Sparse matrix in Data Structure\" width=\"260\" height=\"258\" \/><\/a><\/p>\n<p>Thus, a sparse matrix is a matrix in which the number of zeros is more than the number of non-zero elements. If we store this sparse matrix as it is, it will consume a lot of space. Therefore, we store only non-zero values in the memory in a more efficient way.<\/p>\n<h3>Why Sparse Matrix:<\/h3>\n<p>There are mainly two reasons for using sparse matrices. These are:<\/p>\n<p><strong>1. Computation time:<\/strong> If we store the sparse matrix in a memory-efficient manner, we can save a lot of computational time to perform operations on the matrix.<\/p>\n<p><strong>2. Storage:<\/strong> When we store only non-zero elements, we can save a lot of memory\/space that we can use for storing other data structures or performing other operations.<\/p>\n<h3>Memory Representation of Sparse Matrix:<\/h3>\n<p>There are two types of representations for sparse matrices. These are based on the type of data structure used to store the sparse matrix. Based on this, the representations are:<\/p>\n<p>1. Array representation<br \/>\n2. Linked list representation<\/p>\n<h4>Array Representation:<\/h4>\n<p>In an array representation, we make use of arrays to store a sparse matrix. The sparse matrix is stored in a 2-D array having three rows as follows:<\/p>\n<p><strong>1. Row:<\/strong> It stores the index of the row, where we have a non-zero element in the sparse matrix.<\/p>\n<p><strong>2. Column:<\/strong> It stores the index of the column, where we have the non-zero element in the sparse matrix.<\/p>\n<p><strong>3. Value:<\/strong> This variable consists of the actual non-zero value being stored.<\/p>\n<p>For example, the following diagram shows how we can represent a sparse matrix with the help of an array by storing only non-zero elements in the array along with their row number and column number.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84896\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image02.jpg\" alt=\"Array Representation in data Structure\" width=\"637\" height=\"336\" \/><\/a><\/p>\n<h4>Linked List Representation:<\/h4>\n<p>A linked list is a combination of interconnected rows joined in a linear manner. In linked list representation, each node consists of four components:<\/p>\n<p><strong>1. Row:<\/strong> It stores the index of the row, where we have a non-zero element in the sparse matrix.<\/p>\n<p><strong>2. Column:<\/strong> It stores the index of the column, where we have the non-zero element in the sparse matrix.<\/p>\n<p><strong>3. Value:<\/strong> This variable consists of the actual non-zero value being stored.<\/p>\n<p><strong>4. Next node:<\/strong> It is a pointer to store the address of the next connected node.<\/p>\n<p>Thus, we can represent the node as follows:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84897\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image03.jpg\" alt=\"Sparse matrix in DS\" width=\"643\" height=\"203\" \/><\/a><\/p>\n<p>In the following diagram, we can see the linked list representation of a sparse matrix.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84898\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-Sparse-matrix-in-DS-normal-image04.jpg\" alt=\"Linked list in data structure\" width=\"1217\" height=\"258\" \/><\/a><\/p>\n<h3>Array Implementation in C:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int main()\n{\n  int sparse_matrix[5][4] =\n  {\n    {0, 0, 3, 0},\n    {0, 0, 5, 7},\n    {0, 0, 0, 0},\n    {0, 2, 6, 0},\n    {4, 0, 0, 0}\n  };\n\n  int size = 0;\n  for (int i = 0; i &lt; 5; i++)\n    for (int j = 0; j &lt; 4; j++)\n      if (sparse_matrix[i][j] != 0)\n        size++;\n\n  int new_matrix[3][size];\n  int k = 0;\n  for (int i = 0; i &lt; 5; i++)\n    for (int j = 0; j &lt; 4; j++)\n      if (sparse_matrix[i][j] != 0)\n      {\n        new_matrix[0][k] = i;\n        new_matrix[1][k] = j;\n        new_matrix[2][k] = sparse_matrix[i][j];\n        k++;\n      }\n  for (int i=0; i&lt;3; i++)\n  {\n    for (int j=0; j&lt;size; j++)\n      printf(\"%d \", new_matrix[i][j]);\n    printf(\"\\n\");\n  }\n  return 0;\n}\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0 1 1 3 3 4<br \/>\n2 2 3 1 2 0<br \/>\n3 5 7 2 6 4<\/div>\n<h3>Array Implementation in C++:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;bits\/stdc++o.h&gt;\n\nint main()\n{\n  int sparse_matrix[5][4] =\n  {\n    {0, 0, 3, 0},\n    {0, 0, 5, 7},\n    {0, 0, 0, 0},\n    {0, 2, 6, 0},\n    {4, 0, 0, 0}\n  };\n\n  int size = 0;\n  for (int i = 0; i &lt; 5; i++)\n    for (int j = 0; j &lt; 4; j++)\n      if (sparse_matrix[i][j] != 0)\n        size++;\n\n  int new_matrix[3][size];\n  int k = 0;\n  for (int i = 0; i &lt; 5; i++)\n    for (int j = 0; j &lt; 4; j++)\n      if (sparse_matrix[i][j] != 0)\n      {\n        new_matrix[0][k] = i;\n        new_matrix[1][k] = j;\n        new_matrix[2][k] = sparse_matrix[i][j];\n        k++;\n      }\n  for (int i=0; i&lt;3; i++)\n  {\n    for (int j=0; j&lt;size; j++)\n      cout &lt;&lt; new_matrix[i][j];\n    cout &lt;&lt; endl;\n  }\n  return 0;\n}\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0 1 1 3 3 4<br \/>\n2 2 3 1 2 0<br \/>\n3 5 7 2 6 4<\/div>\n<h3>Array Implementation in Java:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class TechVidvan\n{\n\n  public static void main(String[] args)\n  {\n    int sparse_matrix[][]\n        = {\n          {0, 0, 3, 0},\n               \t\t\t{0, 0, 5, 7},\n                \t\t{0, 0, 0, 0},\n                \t\t{0, 2, 6, 0},\n               \t\t\t {4, 0, 0, 0}\n        };\n\n    int size = 0;\n    for (int i = 0; i &lt; 5; i++)\n    {\n      for (int j = 0; j &lt; 4; j++)\n      {\n        if (sparse_matrix[i][j] != 0)\n          size++;\n      }\n    }\n\n    int new_matrix[][] = new int[3][size];\n    int k = 0;\n    for (int i = 0; i &lt; 4; i++)\n    {\n      for (int j = 0; j &lt; 5; j++)\n      {\n        if (sparse_matrix[i][j] != 0)\n        {\n          new_matrix[0][k] = i;\n          new_matrix[1][k] = j;\n          new_matrix[2][k] = sparse_matrix[i][j];\n          k++;\n        }\n      }\n    }\n\n    for (int i = 0; i &lt; 3; i++)\n    {\n      for (int j = 0; j &lt; size; j++)\n      {\n        System.out.print(\"%d \", new_matrix[i][j]);\n      }\n      System.out.print(\"\\n\");\n    }\n  }\n}\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0 1 1 3 3 4<br \/>\n2 2 3 1 2 0<br \/>\n3 5 7 2 6 4<\/div>\n<h3>Array Implementation in Python:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sparse_matrix = [[0,0,3,0],[0,0,5,7],[0,0,0,0],[0,2,6,0],[4,0,0,0]]\n\nsize = 0\n\nfor i in range(5):\n  for j in range(4):\n    if (sparse_matrix[i][j] != 0):\n      size += 1\n\n\nrows, cols = (3, size)\nnew_matrix = [[0 for i in range(cols)] for j in range(rows)]\n\nk = 0\nfor i in range(5):\n  for j in range(4):\n    if (sparse_matrix[i][j] != 0):\n      new_matrix[0][k] = i\n      new_matrix[1][k] = j\n      new_matrix[2][k] = sparse_matrix[i][j]\n      k += 1\n\nfor i in new_matrix:\n  print(i)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0 1 1 3 3 4<br \/>\n2 2 3 1 2 0<br \/>\n3 5 7 2 6 4<\/div>\n<h3>Linked List Implementation in C:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\n#include&lt;stdlib.h&gt;\n\nstruct Node\n{\n  int key;\n  int row_position;\n  int col_postion;\n  struct Node *Next;\n};\n\nvoid create_new_node(struct Node** head, int non_zero_element,\n          int row_index, int col_index )\n{\n  struct Node *temp, *r;\n  temp = *head;\n  if (temp == NULL)\n  {\n    temp = (struct Node *) malloc (sizeof(struct Node));\n    temp-&gt;key = non_zero_element;\n    temp-&gt;row_position = row_index;\n    temp-&gt;col_postion = col_index;\n    temp-&gt;Next = NULL;\n    *head = temp;\n\n  }\n  else\n  {\n    while (temp-&gt;Next != NULL)\n      temp = temp-&gt;Next;\n    r = (struct Node *) malloc (sizeof(struct Node));\n    r-&gt;key = non_zero_element;\n    r-&gt;row_position = row_index;\n    r-&gt;col_postion = col_index;\n    r-&gt;Next = NULL;\n    temp-&gt;Next = r;\n\n  }\n}\n\nvoid Print_list(struct Node* head)\n{\n  struct Node *temp, *r, *s;\n  temp = r = s = head;\n\n  printf(\"row_position: \");\n  while(temp != NULL)\n  {\n\n    printf(\"%d \", temp-&gt;row_position);\n    temp = temp-&gt;Next;\n  }\n  printf(\"\\n\");\n\n  printf(\"col_postion: \");\n  while(r != NULL)\n  {\n    printf(\"%d \", r-&gt;col_postion);\n    r = r-&gt;Next;\n  }\n  printf(\"\\n\");\n  printf(\"Value: \");\n  while(s != NULL)\n  {\n    printf(\"%d \", s-&gt;key);\n    s = s-&gt;Next;\n  }\n  printf(\"\\n\");\n}\n\nint main()\n{\n  int sparse_matric[5][4] =\n  {\n    {0, 0, 3, 0},\n    {0, 0, 5, 7},\n    {0, 0, 0, 0},\n    {0, 2, 6, 0},\n    {4, 0, 0, 0}\n  };\n\n  struct Node* start = NULL;\n\n  for (int i = 0; i &lt; 5; i++)\n    for (int j = 0; j &lt; 4; j++)\n      if (sparse_matric[i][j] != 0)\n        create_new_node(&amp;head, sparse_matric[i][j], i, j);\n\n  Print_list(head);\n\n  return 0;\n}\n<\/pre>\n<h3>Linked List Implementation in C++:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;bits\/stdc++.h&gt;\n\nstruct Node\n{\n  int key;\n  int row_position;\n  int col_postion;\n  struct Node *Next;\n};\n\nvoid create_new_node(struct Node** head, int non_zero_element,\n          int row_index, int col_index )\n{\n  struct Node *temp, *r;\n  temp = *head;\n  if (temp == NULL)\n  {\n    temp = (struct Node *) malloc (sizeof(struct Node));\n    temp-&gt;key = non_zero_element;\n    temp-&gt;row_position = row_index;\n    temp-&gt;col_postion = col_index;\n    temp-&gt;Next = NULL;\n    *head = temp;\n\n  }\n  else\n  {\n    while (temp-&gt;Next != NULL)\n      temp = temp-&gt;Next;\n    r = (struct Node *) malloc (sizeof(struct Node));\n    r-&gt;key = non_zero_element;\n    r-&gt;row_position = row_index;\n    r-&gt;col_postion = col_index;\n    r-&gt;Next = NULL;\n    temp-&gt;Next = r;\n\n  }\n}\n\nvoid Print_list(struct Node* head)\n{\n  struct Node *temp, *r, *s;\n  temp = r = s = head;\n\n  cout &lt;&lt; \"row_position: \";\n  while(temp != NULL)\n  {\n\n    cout &lt;&lt; temp-&gt;row_position;\n    temp = temp-&gt;Next;\n  }\n  cout &lt;&lt; endl;\n\n  cout &lt;&lt; \"col_postion: \";\n  while(r != NULL)\n  {\n    cout &lt;&lt; r-&gt;col_postion;\n    r = r-&gt;Next;\n  }\n  cout &lt;&lt; endl;\n  cout &lt;&lt; \"Value: \";\n  while(s != NULL)\n  {\n    cout &lt;&lt; s-&gt;key;\n    s = s-&gt;Next;\n  }\n  cout &lt;&lt; endl;\n}\n\nint main()\n{\n  int sparse_matric[5][4] =\n  {\n    {0, 0, 3, 0},\n    {0, 0, 5, 7},\n    {0, 0, 0, 0},\n    {0, 2, 6, 0},\n    {4, 0, 0, 0}\n  };\n\n  struct Node* start = NULL;\n\n  for (int i = 0; i &lt; 5; i++)\n    for (int j = 0; j &lt; 4; j++)\n      if (sparse_matric[i][j] != 0)\n        create_new_node(&amp;head, sparse_matric[i][j], i, j);\n\n  Print_list(head);\n\n  return 0;\n}\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">row_position: 0 1 1 3 3 4<br \/>\ncol_position: 2 2 3 1 2 0<br \/>\nkey: 3 5 7 2 6 4<\/div>\n<h3>Linked List Implementation in Python:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class Node:\n  __slots__ = \"row\", \"col\", \"key\", \"Next\"\n  def __init__(self, row=0, col=0, key=0, Next=None):\n\n    self.row = row\n    self.col = col\n    self.key = key\n    self.Next = Next\n\nclass Sparse:\n  def __init__(self):\n    self.head = None\n    self.temp = None\n    self.size = 0\n  def __len__(self):\n    return self.size\n    \n  def is_empty(self):\n    return self.size == 0\n\n  def create_new_node(self, row, col, key):\n    new_node = Node(row, col, key, None)\n    if self.is_empty():\n      self.head = new_node\n    else:\n      self.temp.Next = new_node\n    self.temp = new_node\n    self.size += 1\n\n  def Print_list(self):\n    temp = r = s = self.head\n    print(\"row_position:\", end=\" \")\n    while temp != None:\n      print(temp.row, end=\" \")\n      temp = temp.Next\n    print()\n    print(\"col_postion:\", end=\" \")\n    while r != None:\n      print(r.col, end=\" \")\n      r = r.Next\n    print()\n    print(\"Value:\", end=\" \")\n    while s != None:\n      print(s.key, end=\" \")\n      s = s.Next\n    print()\n\nif __name__ == \"__main__\":\n  s = Sparse()\n  sparse_matrix = [[0, 0, 3, 0],\n          [0, 0, 5, 7],\n          [0, 0, 0, 0],\n          [0, 2, 6, 0],\n          [4, 0, 0, 0]]\n  for i in range(5):\n    for j in range(4):\n      if sparse_matric[i][j] != 0:\n        s.create_new_node(i, j, sparse_matric[i][j])\n  s.Print_list()\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">row_position: 0 1 1 3 3 4<br \/>\ncol_position: 2 2 3 1 2 0<br \/>\nkey: 3 5 7 2 6 4<\/div>\n<h3>Conclusion:<\/h3>\n<p>In this article, we have discussed what is a sparse matrix, how do we define it, what is the need for a sparse matrix and how we can implement it in various programming languages. Thus, a sparse matrix is a very beneficial way of representing matrices as it reduces the computational time to a great extent.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In programming, we usually represent a 2-D array in the form of a matrix. However, if a matrix has most of its elements equal to zero, then the matrix is known as a sparse&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":84893,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3555],"tags":[4265,4266],"class_list":["post-84189","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-structure","tag-sparse-matrix","tag-sparse-matrix-in-data-structure"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Sparse Matrix in Data Structure - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn what is a sparse matrix, how to define it, what is its need and how we can implement it in various programming languages.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sparse Matrix in Data Structure - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn what is a sparse matrix, how to define it, what is its need and how we can implement it in various programming languages.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-21T03:30:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-Sparse-matrix-in-DS-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sparse Matrix in Data Structure - TechVidvan","description":"Learn what is a sparse matrix, how to define it, what is its need and how we can implement it in various programming languages.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/","og_locale":"en_US","og_type":"article","og_title":"Sparse Matrix in Data Structure - TechVidvan","og_description":"Learn what is a sparse matrix, how to define it, what is its need and how we can implement it in various programming languages.","og_url":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-09-21T03:30:34+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-Sparse-matrix-in-DS-1.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Sparse Matrix in Data Structure","datePublished":"2021-09-21T03:30:34+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/"},"wordCount":589,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-Sparse-matrix-in-DS-1.jpg","keywords":["Sparse Matrix","Sparse Matrix in data structure"],"articleSection":["Data Structure Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/","url":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/","name":"Sparse Matrix in Data Structure - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-Sparse-matrix-in-DS-1.jpg","datePublished":"2021-09-21T03:30:34+00:00","description":"Learn what is a sparse matrix, how to define it, what is its need and how we can implement it in various programming languages.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-Sparse-matrix-in-DS-1.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-Sparse-matrix-in-DS-1.jpg","width":1200,"height":628,"caption":"Sparse Matrix in data structure"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/sparse-matrix-in-data-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Sparse Matrix in Data Structure"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=84189"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84189\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/84893"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=84189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=84189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=84189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}