Let me talk about what is a sparse matrix. You said, this question is very simple, then you must not know the mouth of the Chinese academic circles, the "" "" will lead to two opposite conclusions. This is a test research on Tsinghua 2000: "indicates how many matrix elements have a matrix element with a 1000 top point, a 1000-side view matrix? Is it sparse matrix?" If you are a psychological activity like to study the topic People, you can see that there are two traps here, it is to let the people who have a clear meeting, I don't want to say what is, leaving to readers. No matter what the standard answer given by Tsinghua, the reference book is a stricken "data structure (C language version)", the definition of the sparse matrix in the book: "Non-zero yuan is less zero yuan (Note: The original book gives a roughly extent), and there is no regularity of the distribution. "With this statement, the answer should not be a sparse matrix, as it may be a special matrix (non-zero component distribution regular). Since I change the reference book in 2002, many concepts have changed. The most obvious is from how much start counting (0 or 1), resulting in the height of the empty tree becomes -1, only one root node tree height is 0. Unfortunately, the problem of tree is high. I have been taking care of you. When you go to your pen, you always have a little bit, it is not a chairman of the emperor, will you answer a compatible version? Then, the topic of the new reference book is quoted in the exam, the answer is a sparse matrix. You may be surprised that salted fish will swim, but this answer and book are not contradictory, because in this shadow, there is no special matrix, and naturally, it must be a sparse matrix. In fact, these two books have no principled problems on this issue. The C version is a special matrix and sparse matrix from the data structure implementation. After all, they have achieved very different; the new book has a small matrix of non-zero yuan It is used as a sparse matrix. When you do it in this idea, you will find that the special non-zero yuan of various structures, if you use the cross-linked list, you are unique to the special structure that takes into account its special structure. The storage method is just a waste of several head nodes and some pointer domains, and there is a decrease in the efficiency of the operation. From my personal point of view, I prefer more unity, less special, even if I sacrifice a little efficiency; so I agree with the new reference book. At the beginning of the count, I prefer the original practice; after all, research the data structure should consider people's thinking habits, not what computer likes; you have to say the first element in the table is the 0th, empty tree Is -1, why not let people feel the heart. The data structure is a bridge, intermediary that people think and computer-implemented during construction algorithms, which should be in line with human thinking habits, even if they do some conversions inside it when it is implemented. I started nonsense so much, I hope I didn't dispel my mood, good, the words retired.
The crosslinks here are constituted: using the chain table to simulate the row (or column, this can be determined according to personal preference), then construct the representative column linked list, insert the element node in each row into the corresponding column. go with. In the book, in order to survive a few head nodes, the books and columns will be merged together - actually only saved several pointer domains, if the lines and columns are inequal, and the extra data domains will save this provision. The space is used again. This little movement makes me a half-day strength, personal feeling, unparalleled advantages, a lot of shortcomings, it is better to write like a cross-chain table, people also look at some, this is a textbook, the purpose is to teach. Really look at the people, see this part of the C version, very clear. I will not draw, make an alteration: this cross-list logical structure is like a Go panel (I haven't seen it, you want to shoot, this is always seen), not zero yuan. Chess pieces placed on the board, the total space is to determine the head nodes of those lines and non-zero nodes represented by those chess pieces. Finally, we pointed to this board with a pointer, which represents this sparse matrix. Now, let's take a look at which few domains in the non-zero node, Data must, down, Right put line painting, it seems that there is no need. Take a look at the head node, because it is a header node of the list, it is the same as the node behind. Then, the header node of the routing list and the column list actually constitutes a linked list, and we add a public header node to them. Finally, we can access the sparse matrix by pointing to the pointer of the public header node of the linked list of this row list header.
It seems to be different from the book - the non-zero element node has I, J, in fact, for determining non-zero yuan in the matrix, i, j is not necessary, watching the Go Dish you will very clear. But very unfortunate, not to save them, do things, at least, you must consider the efficiency of addition and multiplication, please think about how to complete it with the above structure. Considering that many words have been written here, I will implement the part in the next article, I should rest today.