Data structure-4.5 strings, arrays and generalized tables

Preface-Data Structure

The data structure needs to be chewed repeatedly, and the answers to the problems encountered in the development can be obtained at any time.

Array

Symmetric matrix (special matrix compression storage)

  • Symmetric matrix elements can only store the lower triangular part, requiring a total of n(n+1) 2 units of space (the storage method of triangular matrices is similar)
    Insert picture description here
  • Taking a one-dimensional array sa[] as the storage structure of the n-th order symmetric matrix A, there is the following correspondence between any element aij in A and its storage location sa[k]:
    Insert picture description here
  • The formula of a symmetric matrix: a53 = 5*(5+1)/2 + 3 = 18

Band matrixInsert picture description here

sparse matrix

  • Thinking about how to store it, how it is stored
    Insert picture description here

Sparse matrix storage: row and column values

Insert picture description here

Cross linked list

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_41732253/article/details/109547481