{"id":16080,"date":"2023-05-05T06:10:54","date_gmt":"2023-05-05T06:10:54","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=16080"},"modified":"2023-05-05T06:10:54","modified_gmt":"2023-05-05T06:10:54","slug":"sparse-matrix-in-data-structure","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/","title":{"rendered":"Sparse Matrix in Data Structure"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg\" alt=\"\" \/><\/p>\n<p>A sparse matrix in data structure is an important concept in data structures and algorithms, providing an efficient way to store and process large matrices Sparse matrices are widely used in many fields, including scientific computing, machine learning, and image processing, where large matrices arise frequently.<\/p>\n<h2>What is Sparse Matrix in Data Structure?<\/h2>\n<p>In computer science, a sparse matrix in the data structure is a matrix that has a large number of zero values compared to its total number of elements. Storing these matrices using a dense array representation would be inefficient in terms of both memory and computation time. To overcome this problem, sparse matrices can be represented using a more efficient data structure that only stores the non-zero elements. This can save memory and computation time for certain types of operations, such as matrix multiplication and inversion, and is an important concept in data structures and algorithms.<\/p>\n<h3>Representation of Sparse Matrix in Data Structure<\/h3>\n<p>Sparse matrix in data structure can be represented in two ways:<\/p>\n<ol>\n<li>Array representation<\/li>\n<li>Linked list representation<\/li>\n<\/ol>\n<ul>\n<li>\n<p><strong>Array Representation of Sparse Matrix in Data Structure<\/strong><br \/>\nStoring a sparse matrix in a 2D array can result in a lot of memory wastage because zero elements in the matrix do not carry any useful information, yet they occupy memory space. To overcome this limitation and optimize memory usage, we can represent a sparse matrix by only storing its non-zero elements. This approach reduces both traversal time and storage space requirements. By storing only the non-zero elements, we can achieve a more efficient representation of sparse matrices in data structures.<\/p>\n<p>In the 2D array representation of a sparse matrix, there are typically three fields used to store the relevant information.<br \/>\nThe given below are fields of the array representation of the sparse matrix:<\/p>\n<ul>\n<li><strong>Row index field:<\/strong> This field stores the row indices of non-zero elements in the matrix.<\/li>\n<li><strong>Column index field:<\/strong> This field stores the column indices of non-zero elements in the matrix.<\/li>\n<li><strong>Value field:<\/strong> This field stores the actual values of the non-zero elements in the matrix.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326434-1%20%2837%29.png\" alt=\"\" \/><\/p>\n<p><strong>Implementation of array representation of the sparse matrix in data structure:<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_16082 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_16082 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_16082 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_16082 .wpsm_nav-tabs > li.active > a, #tab_container_16082 .wpsm_nav-tabs > li.active > a:hover, #tab_container_16082 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_16082 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_16082 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_16082 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_16082 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_16082 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_16082 .wpsm_nav-tabs > li > a:hover , #tab_container_16082 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_16082 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_16082 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_16082 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_16082 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_16082 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_16082 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_16082 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16082 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_16082 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16082 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_16082 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_16082\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_16082\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_16082_1\" aria-controls=\"tabs_desc_16082_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C++<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_16082\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_16082_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include &lt;iostream&gt;\r\nusing namespace std;\r\n\r\nconst int MAX = 100;\r\n\r\nint main() {\r\n    int sparse_matrix[4][5] = {  \r\n        {0 , 0 , 6 , 0 , 9 },  \r\n        {0 , 0 , 4 , 6 , 0 },  \r\n        {0 , 0 , 0 , 0 , 0 },  \r\n        {0 , 1 , 2 , 0 , 0 }  \r\n    };\r\n\r\n    int rows = 4, cols = 5;\r\n    int size = 0;\r\n\r\n    \/\/ count the number of non-zero elements\r\n    for(int i=0; i&lt;rows; i++) {\r\n        for(int j=0; j&lt;cols; j++) {\r\n            if(sparse_matrix[i][j] != 0) {\r\n                size++;\r\n            }\r\n        }\r\n    }\r\n\r\n    \/\/ initialize arrays to store row, col, and value\r\n    int row[size], col[size], value[size];\r\n    int k = 0;\r\n\r\n    \/\/ store the non-zero elements in arrays\r\n    for(int i=0; i&lt;rows; i++) {\r\n        for(int j=0; j&lt;cols; j++) {\r\n            if(sparse_matrix[i][j] != 0) {\r\n                row[k] = i;\r\n                col[k] = j;\r\n                value[k] = sparse_matrix[i][j];\r\n                k++;\r\n            }\r\n        }\r\n    }\r\n\r\n    \/\/ display the sparse matrix\r\n    cout &lt;&lt; \"Array Representation of Sparse Matrix:\" &lt;&lt; endl;\r\n    cout &lt;&lt; \"Row&#92;tCol&#92;tValue\" &lt;&lt; endl;\r\n    for(int i=0; i&lt;size; i++) {\r\n        cout &lt;&lt; row[i] &lt;&lt; \"&#92;t\" &lt;&lt; col[i] &lt;&lt; \"&#92;t\" &lt;&lt; value[i] &lt;&lt; endl;\r\n    }\r\n\r\n    return 0;\r\n}\r\n<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_16082 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_16082 a\"),jQuery(\"#tab-content_16082\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Explanation of array representation of the sparse matrix in data structure:<\/strong><br \/>\nThe array representation of the sparse matrix in the data structure program converts a given matrix into its array representation where the non-zero elements of the matrix are stored in separate arrays for row, column, and value. It first counts the number of non-zero elements in the matrix, then initializes the arrays and stores the non-zero elements in them. Finally, it displays the array representation of the matrix. This program can reduce the storage space required for large matrices with many zero elements.<\/p>\n<\/li>\n<li>\n<p><strong>Linked List Representation of Sparse Matrix in Data Structure<\/strong><br \/>\nThe sparse matrix in data structure can be represented using a linked list data structure, which offers the advantage of lower complexity when inserting or deleting a node compared to an array.<\/p>\n<p>The linked list representation differs from the array representation in that each node has four fields, which are:<\/p>\n<ul>\n<li><strong>Row:<\/strong> It indicates the index of the row where the non-zero element is located.<\/li>\n<li><strong>Column:<\/strong> It indicates the index of the column where the non-zero element is located.<\/li>\n<li><strong>Value:<\/strong> It represents the value of the non-zero element located at the index (row, column).<\/li>\n<li><strong>Pointer to Next node:<\/strong> It stores the memory address of the next node in the linked list.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326434-2%20%2821%29.png\" alt=\"\" \/><\/p>\n<p><strong>Implementation of linked list representation of sparse matrix:<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_16083 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_16083 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_16083 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_16083 .wpsm_nav-tabs > li.active > a, #tab_container_16083 .wpsm_nav-tabs > li.active > a:hover, #tab_container_16083 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_16083 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_16083 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_16083 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_16083 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_16083 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_16083 .wpsm_nav-tabs > li > a:hover , #tab_container_16083 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_16083 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_16083 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_16083 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_16083 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_16083 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_16083 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_16083 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16083 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_16083 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16083 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_16083 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_16083\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_16083\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_16083_1\" aria-controls=\"tabs_desc_16083_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C++<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_16083\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_16083_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include &lt;iostream&gt;\r\nusing namespace std;\r\n\r\nclass Node {\r\npublic:\r\n    int col;\r\n    int val;\r\n    Node* next;\r\n};\r\n\r\nclass SparseMatrix {\r\nprivate:\r\n    int m, n; \/\/ dimensions of matrix\r\n    Node** rows;\r\npublic:\r\n    SparseMatrix(int rows, int cols) {\r\n        m = rows;\r\n        n = cols;\r\n        this-&gt;rows = new Node * [m];\r\n        for (int i = 0; i &lt; m; i++) {\r\n            this-&gt;rows[i] = NULL;\r\n        }\r\n    }\r\n    void insert(int i, int j, int val) {\r\n        if (i &lt; 0 || i &gt;= m || j &lt; 0 || j &gt;= n) {\r\n            cout &lt;&lt; \"Invalid index!\" &lt;&lt; endl;\r\n            return;\r\n        }\r\n        Node* node = new Node;\r\n        node-&gt;col = j;\r\n        node-&gt;val = val;\r\n        node-&gt;next = NULL;\r\n        if (rows[i] == NULL) {\r\n            rows[i] = node;\r\n        }\r\n        else {\r\n            Node* prev = NULL;\r\n            Node* curr = rows[i];\r\n            while (curr != NULL &amp;&amp; curr-&gt;col &lt; j) {\r\n                prev = curr;\r\n                curr = curr-&gt;next;\r\n            }\r\n            if (curr != NULL &amp;&amp; curr-&gt;col == j) {\r\n                curr-&gt;val = val;\r\n                delete node;\r\n            }\r\n            else {\r\n                node-&gt;next = curr;\r\n                if (prev == NULL) {\r\n                    rows[i] = node;\r\n                }\r\n                else {\r\n                    prev-&gt;next = node;\r\n                }\r\n            }\r\n        }\r\n    }\r\n    void display() {\r\n        for (int i = 0; i &lt; m; i++) {\r\n            Node* curr = rows[i];\r\n            for (int j = 0; j &lt; n; j++) {\r\n                if (curr != NULL &amp;&amp; curr-&gt;col == j) {\r\n                    cout &lt;&lt; curr-&gt;val &lt;&lt; \" \";\r\n                    curr = curr-&gt;next;\r\n                }\r\n                else {\r\n                    cout &lt;&lt; \"0 \";\r\n                }\r\n            }\r\n            cout &lt;&lt; endl;\r\n        }\r\n    }\r\n    ~SparseMatrix() {\r\n        for (int i = 0; i &lt; m; i++) {\r\n            Node* curr = rows[i];\r\n            while (curr != NULL) {\r\n                Node* temp = curr;\r\n                curr = curr-&gt;next;\r\n                delete temp;\r\n            }\r\n        }\r\n        delete[] rows;\r\n    }\r\n};\r\n\r\nint main() {\r\n    SparseMatrix mat(3, 3);\r\n    mat.insert(0, 0, 1);\r\n    mat.insert(0, 1, 0);\r\n    mat.insert(0, 2, 0);\r\n    mat.insert(1, 0, 0);\r\n    mat.insert(1, 1, 2);\r\n    mat.insert(1, 2, 0);\r\n    mat.insert(2, 0, 0);\r\n    mat.insert(2, 1, 0);\r\n    mat.insert(2, 2, 3);\r\n    mat.display();\r\n    return 0;\r\n}\r\n<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_16083 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_16083 a\"),jQuery(\"#tab-content_16083\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Explanation of  linked list representation of the sparse matrix:<\/strong><br \/>\nIn the implementation of a linked list representation of a sparse matrix, the Node class represents a node in the linked list for a particular row. The SparseMatrix class contains a dynamic array of pointers to nodes, where each pointer points to the head of the linked list for a particular row. The insert function inserts a new element into the matrix by creating a new Node and inserting it into the appropriate linked list, sorted by column index. The display function prints out the entire matrix by iterating over each row and column and checking the linked list for each row to see if there is a corresponding element<\/p>\n<\/li>\n<\/ul>\n<p><strong>Conclusion<\/strong><br \/>\nIn conclusion, a sparse matrix in data structure is a type of matrix that contains a significant number of zero values. To represent such matrices efficiently, we use a data structure that can store only the non-zero values and their corresponding row and column indices. One popular data structure for representing sparse matrices is the linked list. The linked list representation of a sparse matrix allows for efficient insertion and deletion operations, as well as lower storage requirements compared to dense matrix representations. By using the appropriate data structure, we can optimize the storage and processing of sparse matrices in various applications.<\/p>\n<h2>Frequently Asked Questions(FAQs)<\/h2>\n<p><strong>Q1. What is the difference between a dense matrix and a sparse matrix?<\/strong><br \/>\n<strong>Ans:<\/strong> A dense matrix is a matrix in which a large proportion of the elements are non-zero, while a sparse matrix is a matrix in which a large proportion of the elements are zero.<\/p>\n<p><strong>Q2. What is the advantage of using a sparse matrix representation over a dense matrix representation?<\/strong><br \/>\n<strong>Ans:<\/strong> The advantage of using a sparse matrix representation is that it can save memory and computation time by only storing the non-zero elements of the matrix. This is especially beneficial for very large matrices with a high proportion of zero elements.<\/p>\n<p><strong>Q3. What are some common operations that can be performed more efficiently on a sparse matrix than on a dense matrix?<\/strong><br \/>\n<strong>Ans:<\/strong> Some common operations that can be performed more efficiently on a sparse matrix include matrix multiplication, matrix inversion, and solving linear equations.<\/p>\n<p><strong>Q4. What are some common data structures used to represent sparse matrices?<\/strong><br \/>\n<strong>Ans:<\/strong> Some common data structures used to represent sparse matrices include the compressed sparse row (CSR) format, compressed sparse column (CSC) format, and linked list format.<\/p>\n<p><strong>Q5. How can I efficiently perform matrix multiplication on a sparse matrix?<\/strong><br \/>\n<strong>Ans:<\/strong> Matrix multiplication on a sparse matrix can be performed efficiently using specialized algorithms, such as the CSR or CSC matrix multiplication algorithms. These algorithms take advantage of the sparse structure of the matrices to reduce the number of arithmetic operations required.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A sparse matrix in data structure is an important concept in data structures and algorithms, providing an efficient way to store and process large matrices Sparse matrices are widely used in many fields, including scientific computing, machine learning, and image processing, where large matrices arise frequently. What is Sparse Matrix in Data Structure? In computer [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[191],"tags":[],"class_list":["post-16080","post","type-post","status-publish","format-standard","hentry","category-data-structure"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Sparse Matrix in Data Structure<\/title>\n<meta name=\"description\" content=\"A Sparse Matrix in data structure is a matrix that has a large number of zero values compared to its total number of elements.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/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\" \/>\n<meta property=\"og:description\" content=\"A Sparse Matrix in data structure is a matrix that has a large number of zero values compared to its total number of elements.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-05T06:10:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Sparse Matrix in Data Structure\",\"datePublished\":\"2023-05-05T06:10:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/\"},\"wordCount\":1050,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg\",\"articleSection\":[\"Data Structure\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/\",\"name\":\"Sparse Matrix in Data Structure\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg\",\"datePublished\":\"2023-05-05T06:10:54+00:00\",\"description\":\"A Sparse Matrix in data structure is a matrix that has a large number of zero values compared to its total number of elements.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Structure\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/data-structure\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Sparse Matrix in Data Structure\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sparse Matrix in Data Structure","description":"A Sparse Matrix in data structure is a matrix that has a large number of zero values compared to its total number of elements.","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:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/","og_locale":"en_US","og_type":"article","og_title":"Sparse Matrix in Data Structure","og_description":"A Sparse Matrix in data structure is a matrix that has a large number of zero values compared to its total number of elements.","og_url":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2023-05-05T06:10:54+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Sparse Matrix in Data Structure","datePublished":"2023-05-05T06:10:54+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/"},"wordCount":1050,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg","articleSection":["Data Structure"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/","url":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/","name":"Sparse Matrix in Data Structure","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg","datePublished":"2023-05-05T06:10:54+00:00","description":"A Sparse Matrix in data structure is a matrix that has a large number of zero values compared to its total number of elements.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683093326286-Sparse%20matrix%20in%20data%20structure.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/sparse-matrix-in-data-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Data Structure","item":"https:\/\/prepbytes.com\/blog\/category\/data-structure\/"},{"@type":"ListItem","position":3,"name":"Sparse Matrix in Data Structure"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=16080"}],"version-history":[{"count":2,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16080\/revisions"}],"predecessor-version":[{"id":16090,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16080\/revisions\/16090"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=16080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=16080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=16080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}