Professional Documents
Culture Documents
1 Languages
1 Languages
Complexity Theory
Computer problems come in different varieties;
some are easy, and some are hard.?
e.g. sorting an array of large numbers is easy
even for a simple computer.
Scheduling of a time table for a no. of classes
might be too complex and hard for a simple
computer. (class time table examples)
central question of complexity theory is “What
makes some problems computationally hard and
others easy”
2
Complexity Theory
So far researchers have discovered the elegant scheme
for classifying problems according to their
computational difficulty.
You have several options when you confront a problem
that appears to be computationally hard.
1) by understanding which aspect of the problem is at
the root of the difficulty, alter it so that problem is
easily solvable.
2) you may be able to settle for less than a perfect
solution to the problem.
3) Some problems are hard only in the worst case
situation, but easy most of the time.
3
Computability Theory
During the first half of the twentieth century, some
mathematicians discovered that certain basic problems
cannot be solved by computers.
4
Automata Theory
Automata theory deals with the definitions and
properties of mathematical models of computation.
(Mean solve in pictorial form with math)
6
Mathematical Notions and
Terminology
SubSet:
For two sets A and B, we say that A is a subset of B, if
every member of A also is a member of B.
10
Mathematical Notions and
Terminology
Venn diagram.
Venn diagram for the set of English words starting with "t”
11
Mathematical Notions and
Terminology
Venn diagram.
12
Mathematical Notions and
Terminology
Venn diagram.
To represent both sets in the same Venn diagram we
must draw them so that they overlap, indicating that
they share some elements. E.g.
16
Mathematical Notions and
Terminology
Cartesian or Cross product.
17
Mathematical Notions and
Terminology
Functions and Relations.
A function is an object that sets up an input-output
relationship.
A function takes an input and produces an output.
If f is a function whose output value is b when the input
value is a, we write
f(a) = b.
18
Mathematical Notions and
Terminology
Functions Mapping.
20
Mathematical Notions and
Terminology
Functions Domain and Range.
21
Mathematical Notions and
Terminology
Functions Description
We may describe a specific function in several ways.
One way is with a procedure for computing an output
from a specified input.
Another way is with a table that lists all possible inputs
and gives the output for each input.
e.g. one way is
Consider the function f: {O,1,2,3,4} {O,1,2,3,4}.)
Tabular way
22
Mathematical Notions and
Terminology
Graphs
An undirected graph, or simply a graph, is a set of points
with lines connecting some of the points.
The points are called nodes or vertices and the lines are
called edges.
23
Mathematical Notions and
Terminology
Degree of Nodes
The number of edges at a particular node is the degree
of that node.
In a graph G that contains nodes i and j, the pair (i,j)
represents the edge that connects i and j.
The order of i and j does not matter in undirected
graphs so (i,j) and (j,i) represents same edge.
24
Mathematical Notions and
Terminology
Degree of Nodes
25
Mathematical Notions and
Terminology
Usage of Graphs
Graphs are normally used to represent data
Nodes might be cities and edges the connecting
highways
or nodes might be electrical components and edges the
wires between them.
Labeled Graph
Some time we use labeling to represent node and edges,
this is called a labeled graph.
26
Mathematical Notions and
Terminology
Sub-Graphs
A graph G is a sub-graph of graph H if the nodes of G
are a subset of the nodes of H, and the edges of G are
the edges of H on the corresponding nodes.
27
Mathematical Notions and
Terminology
Path
A path in a graph is a sequence of nodes connected by
edges.
Simple Path
A simple path is a path that doesn't repeat any nodes.
Connected graph
29
Mathematical Notions and
Terminology
Directed graph
30
Mathematical Notions and
Terminology
Formal description of Directed graph
The tuple (i,j) and different from (j,i) in directed graph.
31
Strings and Languages
Strings of characters are fundamental building blocks in
computer science.
An alphabet can be any nonempty finite set.
The members of the alphabet are the symbols of the
alphabet.
We generally use capital Greek letter Σ designate
alphabets. (Σ shows alphabets and a,b,c shows symbols
or characters)
e.g.
Σ = {0,1}
Σ= {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}
32
Strings and Languages
A string over an alphabet is a finite sequence of symbols
from that alphabet
Σ = {0,1}
String over the alphabet above: 010001010
Σ= {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}
String: abbcdrrraa.
Length of a string
If w is a string over Σ, the length of w, written |w|, is
the number of symbols that it contains.
33
Strings and Languages
The string of length zero is called the empty string and
is written as Є.
Reversal of a string
The reverse of w, written wR, is the string obtained by
writing w in the opposite order(i.e. if a string s=abc then
reversal of s=cba)
Substring
String z is a sub string of W if z appears consecutively
with in w.
e.g. cad is a substring of abracadabra
34
Strings and Languages
String Concatenation
If we have string x of length m and string y of length n,
the concatenation of x and y, written xy, is the string
obtained by appending y to the end of x
35
Strings and Languages
36
Another Operation
2
abba abbaabba
• Example:
0
w
• Definition:
• 0
abba
37
The **Operation
• : the set of all possible strings from
• alphabet
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
38
The + Operation
: the set of all possible strings from
alphabet except
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
*
a, b, aa, ab, ba, bb, aaa, aab,
39
Example of over
• A language Languages
alphabet
• is any subset of
*
• Examples:
a, b
* , a, b, aa, ab, ba, bb, aaa,
Language:
Language: a, aa, aab
Language: { , abba, baba, aa, ab, aaaaaa}
40
More Language Examples
Alphabet {a , b }
n n
L {a b : n 0}
• An infinite language
ab abb L
L
aabb
aaaaabbbbb
41
Prime numbers
Language:
*
PRIMES {x : x and x is prime}
PRIMES {2,3,5,7,11,13,17, }
42
Even and odd numbers
*
EVEN {x : x and x is even}
EVEN { 0,2,4,6, }
*
ODD {x : x and x is odd}
ODD {1,3,5,7, }
43
Reverse
R R
L {w : w L}
• Definition: R
ab, aab, baba ba, baa, abab
• Examples:
n n
L {a b : n 0}
R n n
L {b a : n 0}
44
Concatenation
L1L2 xy : x L1, y L2
• Definition: