maths.free › Combinatorics & Graph Theory › Strings, Sets, and Binomial Coefficients › Strings: A First Look

Strings: A First Look

Let n be a positive integer. Throughout this text, we will use the shorthand notation [n] to denote the n-element set \{1,2,\dots,n\}. Now let X be a set.

Strings: A First Look

Let \(n\) be a positive integer. Throughout this text, we will use the shorthand notation \([n]\) to denote the \(n\)-element set \(\{1,2,\dots,n\}\). Now let \(X\) be a set. Then a function \(s\colon[n]\rightarrow X\) is also called an \(X\)-string of length \(n\). In discussions of \(X\)-strings, it is customary to refer to the elements of \(X\) as characters, while the element \(s(i)\) is the \(i^{\text{th} }\) character of \(s\). Whenever practical, we prefer to denote a string \(s\) by writing \(s=\) \(x_1x_2x_3\dots x_n\) , rather than the more cumbersome notation \(s(1)=x_1\), \(s(2)=x_2\), , \(s(n)=x_n\).

There are a number of alternatives for the notation and terminology associated with strings. First, the characters in a string \(s\) are frequently written using subscripts as \(s_1,s_2,\dots,s_n\), so the \(i^{\text{th} }\)-term of \(s\) can be denoted \(s_i\) rather than \(s(i)\). Strings are also called sequences, especially when \(X\) is a set of numbers and the function \(s\) is defined by an algebraic rule. For example, the sequence of odd integers is defined by \(s_i=2i-1\).

Alternatively, strings are called words, the set \(X\) is called the alphabet and the elements of \(X\) are called letters. For example, \(aababbccabcbb\) is a \(13\)-letter word on the \(3\)-letter alphabet \(\{a,b,c\}\).

In many computing languages, strings are called arrays. Also, when the character \(s(i)\) is constrained to belong to a subset \(X_i\subseteq X\), a string can be considered as an element of the cartesian product \(X_1\times X_2\times \dots\times X_n\), which is normally viewed as \(n\)-tuples of the form \((x_1,x_2,\dots,x_n)\) such that \(x_i\in X_i\) for all \(i\in [n]\).

In the case that \(X=\{0,1\}\), an \(X\)-string is called a \(0\)\(1\) string (also a binary string or bit string.). When \(X=\{0,1,2\}\), an \(X\)-string is also called a ternary string.

Example

A machine instruction in a \(32\)-bit operating system is just a bit string of length\(32\). Thus, there are \(2\) options for each of \(32\) positions to fill, making the number of such strings \(2^{32} = 4\,294\,967\,296\). In general, the number of bit strings of length\(n\) is \(2^n\).

Condensed: the full section is in Keller & Trotter, Applied Combinatorics.

ឥឡូវ​អ្នក គ្មាន​ម៉ាស៊ីន​គិតលេខ​ដែល​អាច​ដោះស្រាយ​បញ្ហា​នេះ​បាន​ទេ ប៉ុន្តែ​វា​អាច​គណនា​បាន​ ។ ព្យាយាម​មួយ​ខាង​ក្រោម ឬ​វាយ​របស់​អ្នក​ផ្ទាល់ ។

អនុវត្ត (1)

ព្យាយាម​លើ​ក្រដាស​ជា​មុន​សិន ។ បង្ហាញ​ចម្លើយ​ដើម្បី​ពិនិត្យ​មើល ។ ចម្លើយ​ដែល​បាន​ផ្ទៀងផ្ទាត់​អាច​ត្រូវ​បាន​បើក​ក្នុង​កម្មវិធី​ដោះស្រាយ​សម្រាប់​ជំហាន​នីមួយៗ ។

  1. Suppose we are forming strings of length four. The first and second characters in the string will be uppercase English letters. The third character in the string will be a digit (\(0\)\(9\)), and the fourth character in the string will be a lowercase English consonant. How many strings meet these criteria? Explain your reasoning, and it would be better if you expressed your answer as a product of numbers rather than giving only a final numerical answer.

រក្សា​ការ​ធ្វើការ​របស់​អ្នក​ផ្ទាល់

គណនី​ឥត​គិត​ថ្លៃ​បន្ថែម​ចំណាំ​លើ​មេរៀន​នីមួយៗ កំណត់​ហេតុ​នៃ​អ្វី​ដែល​អ្នក​បាន​បញ្ចប់ បញ្ហា​ដែល​អ្នក​បាន​ដោះស្រាយ​នៅ​កន្លែង​មួយ និង​គ្រូ​ដែល​អ្នក​អាច​សួរ​អំពី​ទំព័រ​នេះ ។ គណិតវិទ្យា​ដោយ​ខ្លួន​វា​គឺ​បើក​ចំហ​សម្រាប់​អ្នក​ទាំងអស់​គ្នា ចុះឈ្មោះ​ចូល ឬ​មិន​ចុះឈ្មោះ​ចូល ។

ចុះឈ្មោះ ចូល

និមិត្ត​សញ្ញា​ដែល​បាន​ប្រើ​នៅ​ទីនេះ

ចុច​និមិត្ត​សញ្ញា​ណាមួយ​សម្រាប់​ការ​កំណត់​ពេញលេញ រូបភាព និង​តួអក្សរ​នីមួយៗ​មាន​ន័យ​អ្វី ។

សំណួរ​ដែល​មនុស្ស​សួរ

Permutation or combination?

Ask whether order matters. A lock code is a permutation (order matters); a hand of cards is a combination (it does not).

What is a graph in this sense?

Dots (vertices) joined by lines (edges), not a plot. Road maps, social networks and molecules are graphs; questions like "is there a route" and "how few colours" are graph theory.

ផ្នែក​នៃ​ទំព័រ​នេះ​ត្រូវ​បាន​កែប្រែ​ពី Keller & Trotter, Applied Combinatorics (CC BY-SA 4.0). បន្សំ​និង​ពន្យល់​នៅ​ទីនេះ​ឡើងវិញ កំហុស​គឺ​របស់​យើង ។

បន្ថែម​ទៀត​ក្នុង Combinatorics & Graph Theory