- Sparse array:
- When a majority of the array elements is 0, or a value of the same array is a sparse array can be used to hold the array.
- Treatment: record a total of several odd row, how many different values and the ranks of the value of records with different values of the elements in an array of small-scale, thereby reducing the size of the program.
- Two-dimensional array to a sparse array of ideas:
① traversing original two-dimensional array, the number of valid data obtained sum
② According sum you can create a sparse array aparseArr Int [sum + 1] [3]
③ will be deposited into an effective two-dimensional array of data to sparse arrays
- Sparse array to a two-dimensional array of original ideas:
① first read the first line of sparse arrays, according to the data of the first line, creating an original two-dimensional array
After a few lines of data ② and then read a sparse array, and can be assigned to the original two-dimensional array