You are on page 1of 7

CHAPTER 4

l SEQUENCE AND STRINGS

CHAPTER 4 Sequence
and Strings
LE AR NI NG OUTCOMES
By the end of this chapter, you should be able to:

1. Determine the definition of sequence and strings;

2. Identify the operations that involve sequence and strings; and

3. Experiment self learning with examples and exercises for each topic.

i. 69
SEQUENCE AND STRINGS l CHAPTER 4

INTRODUCTION
Before we begin, let us look at the video as follows.

The video describes the definition of discrete


mathematics. Based form the video, find the
sources on the internet regarding discrete
mathematics and the definition of sequence,
strings, and the operators.

This chapter explains the definition of se-


quence, strings, and the operators that are
involved in the programming of computer
science. A sequence can be represented in or-
dered list of element (integers or characters)
Source: http://www.youtube.com/watch?v=Py_ and usually the values are infinite. The details
QYkMEeH4 about the concept of sequence and strings will
be discussed in this chapter.

4.1 Sequence

n
If bi i =m) is a subsequent, then we can define the sum
and product of terms in the sequence as:

Example 4.1a

1. The sequence of positive even integers:

{2,4,6,…,n,…}

2. The sequence of powers of 2:

{1,2,4,8,…,n2,…}

4. The sequence of Fibonacci numbers (each one is the sum of the two previous
ones)

{0,1,2,3,4,5,8,…,nn+nn-1,…}

70
CHAPTER 4 l SEQUENCE AND STRINGS

Example 4.1b

In general, elements of sequence can also be represented by an indexed letter


such as:

A= {a1,a2,a3,…an,…}

The sequence of all elements can be defined by the given rule:

an=a2+1

The sequence is:

{2,5,10,17,…}

Example 4.1b

We try to take the example in 4.1b and add the value 1 in the sequence below:

{1,2,5,10,17,…}

Then, the sequence is defined by using symbol such as {an} or {an}n =0

4.1.1 Types of Sequence

There are 2 types of sequence to be obtained as represented in Figure 4.1 below:

Sequence Increasing
• For instance where, then the
sequence of elements is
increasing.

Sequence Decreasing
• For instance where then
the sequence of elements is
decreasing.

Figure 4.1: Two types of sequence

i. 71
SEQUENCE AND STRINGS l CHAPTER 4

4.2 Sequence Operation

n
If bi i =m) is a subsequent, then we can define the sum
and product of terms in the sequence as:

n
i = j ai = aj + 1 +…+ an,
n
i = j ai = aj · aj + 1 · … · an

There are 2 types of operations involve. The two operations are shown in Figure 4.2 below:

Sum
n
i = j ai = aj + 1 + aj + 2 + aj + 3 + ... + an

Product Notation
n
i =j ai = aj · aj +1 · aj +2 · aj +3 ·…·an

Figure 4.2: Two type of operation

Example 4.2a

Let say we have ai =n2+1 where 1 i 4 and 1 n 4, then we calculate:


4
i=4 ai=a1 + a2 + a3 + a4
=[12+1]+[22+1]+[32+1]+[42+1]
=2+5+10+17
=34
n=4
i =j ai = a1 · a2 · a3 · a4
=[12+1] · [22+1] · [32+1] · [42+1]
=2 · 5 · 10 · 17
=1700

72
CHAPTER 4 l SEQUENCE AND STRINGS

4.3 Strings

Any finite sequence of symbols that are written one after


the other. Let say, if given S is the set of ={a,b,c,d},
then the following is the strings or words over S: aaba,
aaacc, bbcd, abcd,… etc.

Example 4.3a

In sequence of string, an empty element is called null string and is written as


symbol. For instance:

denotes a set of words.


*
denotes the set of all words over .

If ={m,n}, then S*={?,m,n,mn,nm,mmm,nnn,…}.

Example 4.3b

Let sayM={a,b,c}, then the following are examples of strings over


M:aaa,abaa,abb,abc,ccc,…

The repetitions in string can be specified such as a2 bc2 ab2=aabccabbb etc.

Example 4.3c

Let say Y={a,e,i,o,u}. We can obtain a string over 17 if we let q1=a, q1=o, q2=e,
q3=i, q4=u. The string is written as “aoeiu”.

i. 73
SEQUENCE AND STRINGS l CHAPTER 4

The length of a string a is the number of elements in a.


The length of a is denoted by |a| .

Example 4.3d

If we give a string a=computer and ß=key, then:

|a|=8 a=computer

|ß|=3 | a|=8

|aß|=11

aß = computerkey

If a and ß are two strings, the string will consist of a followed by ß. It can be
written as a ß and is called the concatenation of a and ß.

1. Given a set of S = { j, k, l, m, n}. Determine the following:


(a) S0
(b) S3
(c) S2
(d) Generate 3 strings from the set S.

2. Define Y = 2x + 1 where 1 ≤ x ≤ 5. Generate strings form set Y and define


the sequence as increasing or decreasing.

3. Determine the Σ and Π for the xn = 2n² + n - 1 where 0 ≤ n ≤ 5. Show the


steps for each operation.

4. Given 4 strings γ = abbba ρ = mmmaa α = bcca β = ab


(a) Find the string of ραβ and αβ²γ.
(b) Find the value of |αβ|, |γρα²| and |ββα|.

74
CHAPTER 4 l SEQUENCE AND STRINGS

SUMMARY

1. A sequence must be in ordered list element of infinite.

2. The length of a string a is the number of elements in a. The length of a is denoted by


|a|.

Glossary

Sequence A sequence must be in ordered list element of


infinite N.

String Any finite sequence of symbols that are written


one after the other.

REFERENCES

Bostock, L., & Chandler, S. (1994). Mathematics - The Core Course for A-Level.
NV Usa: Stanley Thornes (Publishers) Ltd.

Johnsonbaugh, R. (2001). Discrete Mathematics (5th ed.). New Jersey: Prentice Hall.

Lipschutz, S. (1982). Theory and Problems of Essential Computer Mathematics.


Usa: McGraw Hill.

Miguel, A. Lerma. (2005). Notes on Discrete Mathematics. Retrieved May 27, 2009,
from Springer Web site: http://new.taringa.net/posts/ebooks-tutoriales/2394021/
Amplia-colección-de-textos-matemáticos.html/

Rosen, K. H. (1999). Discrete Mathematics and Its Applications. McGraw-Hill.

Sobel, M., & Lerner, N. (1995). Algebra and Trigonometry (5th Ed.). London:
Prentice Hall.

i. 75

You might also like