Spring 2015 1.3

advertisement
A
sequence is a list of objects arranged in a
specific order.
 A sequence in computer science is known as
an array. An array hold objects of the same
type
 It may be a finite list, containing a specific
number of elements or it may be an infinite
list.
 The elements may be different or they may
be repeated.
 Recursive:
refers to a previous term
3,8,13,18,23
5 is added to each term to get the next term
 Explicit:
tells what value a particular term
has and is not dependent on the previous
number.
A
list of squares called b.
b contains:
1 as a term
4 as a term
9 as a term
Subscripts are used to indicate the position of
a term in a list.
b1=12
b is the name of the list, 1 is the position of
the term, the value of the term is 12
b2=22
b is the name of the list, 2 is the position of
the term, the value of the term is 22
 The
formula for the square list is:
bn=n2
b1=12
b2=22
b3=32
b4=42
b5=52
The subscript on the left and the value of n on
the right are the same
 List
a
3, 8, 13, 18, 23
a 1 a2 a3 a4 a5
Formula for this list:
An=An-1 + 5 where A1=3
A is the name of the list, n is the subscript,
An-1 refers to the previous term in the list.





A1=3
A2=A2-1+5
A2=A1+5
A2=3+5
A2=8
A3=A3-1+5
A3=A2+5
A3=8+5
A3=13
A4=A4-1+5
A4=A3+5
A4=13+5
A4=18
A5=A5-1+5
A5=A4+5
A5=18+5
A5=23
 Corresponding
set is the set of all distinct
elements in the sequence.
Given the sequence/list:
5,6,5,6,5,6
The set corresponding to the sequence is
{5,6}.
Given the set {a,b} you could have many kinds
of seqeunces. One example would be
a,a,b,b,a,b,b,b,a
 Characteristic

function is denoted f
In binary code, you have a series of 1’s and 0’s
1 represents on or yes
0 represents off or no
 The characteristic function of s, of x, = 1
written: fs(X)=1
If X is an element of S, the outcome is 1
If X is not an element of S, the outcome is 0
fs(X) = 0
 Universal
set U={1,2,3,4,5,6}
subset A = {1,2}
subset B = {2,4,6}
subset C = {4,5,6}
The universal set has 6 terms.
When we compare A to U, the result will have
6 terms
When we compare B to U, the result will have
6 terms
When we compare C to U, the result will have
6 terms.
 The
characteristic function of a = 110000
written: fA = 110000
U={1,2,3,4,5,6}
A={1,2}
fA(1) is 1 an ∈ of A -> Yes fA(1) = 1
fA(2) is 2 an ∈ of A -> Yes fA(2) = 1
fA(3) is 3 an ∈ of A -> No fA(3) = 0
fA(4) is 4 an ∈ of A -> No fA(4) = 0
fA(5) is 5 an ∈ of A -> No fA(5) = 0
fA(6) is 6 an ∈ of A -> No fA(6) = 0
fA = 110000
 U={1,2,3,4,5,6}
B={2,4,6}
fB=010101
 U={1,2,3,4,5,6}
C={4,5,6}
fC=000111
Regular expression (RE):
A regular expression over set A is a string created
from elements of A.
 RE1: The symbol ∧ (meaning empty string) is a
regular expression. An empty string is contained
in the set and is a regular expression
 RE2: if X ∈ A, the symbol X is a regular
expression. The elements of the set are
considered regular expressions.
 RE 3: if
and β are regular expressions, then
the expression
β is regular. In other words, if
the elements are in the set and they are next to
each other, the expression is considered regular.
 RE4: if
β are regular expressions
∨ β is
regular. ∨ means join.

 RE5:
if
is a regular expression
*
(* means finite sequence) is regular.
A*: the set of all finite sequences of
elements of A
*: the set of all finite sequences of
elements of
Download