Compressed Column Sparse Matrix Format (CSC)

Decomposition & Spectral Methods DS practice problem on Onlearn.

Difficulty: easy.

Topics: Understanding Implement Compressed Column Sparse Matrix Format (CSC), CSC Format Structure, Column-Major Iteration, Non-Zero Value Collection, Row Index Preservation, Column Boundary Tracking, Linear Algebra, Data Structures, Algorithm Design, Computational Mathematics, Software Engineering, Matrix Representations, Sparse Matrix Formats, Array Indexing & Manipulation, Space Complexity Analysis, Data Transformation.

Task: Create a Compressed Column Sparse Matrix Representation Your task is to implement a function that converts a dense matrix into its Compressed Column Sparse (CSC) representation. The CSC format stores only non zero elements of the matrix and is efficient for matrices with a high number of zero elements. Write a function compressed col sparse matrix(dense matrix) that takes in a two dimensional list dense matrix and returns a tuple of three lists: values: List of non zero elements, stored in column major order. row indices: List of row indices corresponding to each value in the values array. column pointer: List that indicates the starting index of each column in the values array.