Learning never exhausts the mind.
Article Directory
introduction
The author has always felt that discrete mathematics is an extremely important knowledge base in the study of computer science. The idea of discretization is reflected in all aspects of computer science. For example, the concept of "pixel" is familiar to us in our daily life. Splitting a picture into tiny pixels is to use the idea of discretization. In order to help everyone lay a solid foundation of thinking in discrete mathematics, the author has opened a new column to refine the book "Guide to Discrete Mathematics" to make it easier to understand. This article is the sixth part of this column, mainly introducing Chapter 10.
Chapter 1-3 Portal Portal
4-5 Portal Portal
Chapter 6-7 Portal Portal
Chapter 8 Portal Portal
9 Portal Portal
text
meta package
A metapackage is like a collection with repeated elements, denoted by [ ]. for example:
[a, a, b, b, c] is a metapackage.
Note that the metapackage does not consider the order, but only the type and quantity of elements, that is, [a,b,b,c] and [a,c,b,b] are the same metapackage.
sequence definition
A sequence is like a metapackage that takes order into account, denoted by < >. for example:
<a,b,b,c> is a sequence.
The relationship between sequences and functions
Sequences are special functions.
The sequence <a, b, b, c> can also be written in the functional form of {1→a, 2→b, 3→b, 4→c}.
empty order
A sequence with no elements is an empty sequence.
length
The length of a sequence is the cardinality of the sequence (see cardinality operators in set theory), which is the number of elements in the sequence. If s is a sequence, then #s represents the length of the sequence.
connect
Connection operator ︵, we still use examples to illustrate:
A=<1,2,3>,B=<4,5>,则A︵B=<1,2,3,4,5>
The function of this operator is to "connect" the following sequence to the previous sequence. Another example:
A=<a,b,c>,B=<a,b>,则A︵B=<a,b,c,a,b>
head and tail operator
The head operator (head) returns the first element of the sequence, and the tail operator (tail) returns all elements of the sequence except the head. To illustrate with an example:
A=<a,b,c>,则head A=a,tail A=<b,c>
Notice:
- The head operator returns an element and the tail operator returns a sequence.
- Look at the following sequence, which illustrates that the tail operator returns a sequence with the first element removed:
A=< a >,则head A=a,tail A=< >
limit operator
The ↑ operator returns a subset of a sequence. Let's take an example:
Sequence A=<a, b, b, c>, B={b}, then A↑B=<b, b>
Notice:
- The limit operator returns a sequence
- The sequence it returns follows the order of the elements in the collection on the right side of the operator:
Sequence A=<a, b, b, c>, B={c, b}, then A↑B=<c, b, b>
inversion operator
reverse (reverse operator), reverse the entire sequence. Still use an example to illustrate:
Sequence A=<a, b, c>, then reverse A=<c, b, a>
Injective sequence
Considering the definition of an injective function, it is easy to think that if there is no repeated element in the sequence, then the sequence is an injective sequence.
<a,b,c> is an injective sequence, while <a,b,b,c> is not.
End and epilogue
After the sequence of this book, there is basically nothing worth mentioning, so this column should come to an end here. As the first completed column, at least this column still has thousands of views, which can be regarded as a little consolation for newcomers. Thank you for reading this, and I'm glad if this column helped you; sorry if it didn't. Let's make progress together and encourage each other with you!
I am Shuang_Ai, a newcomer working hard on the road of algorithms, thank you for reading! If you think it is good, you can pay attention to it, and I will bring more and more comprehensive algorithm explanations in the future!