chapter 11 theory of computation. 2 chapter 11: theory of computation 11.1 functions and their...
Post on 21-Dec-2015
236 views
TRANSCRIPT
Chapter 11
Theory of Computation
2
Chapter 11 Theory of Computation 111 Functions and Their
Computation 112 Turing Machines 113 Universal Programming
Languages 114 A Noncomputable Function 115 Complexity of Problems 116 Public Key Cryptography
3
Theory of Computation
--Long before PCs were born there are theories developed to justify what machines can or cannot do
--Any problem that can be solved on a computer has a solution expressed in that corresponding language
--It can be concluded that there are some problems unsolvable by todayrsquos machines or any future algorithmic machine
4
Functions
Measurement of computation power if one machine is capable of computing more functions than another the former is considered the more powerful1048708
Table lookup method can substitute the functions for finite pairs of inputoutputrsquos1048708
Algebraic formulas are better ways to describe the inputoutput associations of many functions V=P(1+r)^n
5
Figure 111 An attempt to display the function that converts measurements in yards into meters
6
Functions
Some functions are too complex to express by algebraic fucntions sin(theta)
Can we find a system for computing fucntions regardless of the complexity
Noncomputable function = a function that cannot be computed by any algorithm
7
Turing Machines
Turing machine introduced by Alan M Turing in 1936 is conceptual device for studying the power of algorithmic processes1048708
It consists of a control unit that can read and write symbols on a tape by a RW head1048708
The tape extends indefinitely at both ends1048708Each cell on the tape can store any one of a finite set of symbolsndashalphabet1048708
At any time it must be in one of a finite number of states including starthalt states1048708
Its computation starts in the start state and ceases in the halt state
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
2
Chapter 11 Theory of Computation 111 Functions and Their
Computation 112 Turing Machines 113 Universal Programming
Languages 114 A Noncomputable Function 115 Complexity of Problems 116 Public Key Cryptography
3
Theory of Computation
--Long before PCs were born there are theories developed to justify what machines can or cannot do
--Any problem that can be solved on a computer has a solution expressed in that corresponding language
--It can be concluded that there are some problems unsolvable by todayrsquos machines or any future algorithmic machine
4
Functions
Measurement of computation power if one machine is capable of computing more functions than another the former is considered the more powerful1048708
Table lookup method can substitute the functions for finite pairs of inputoutputrsquos1048708
Algebraic formulas are better ways to describe the inputoutput associations of many functions V=P(1+r)^n
5
Figure 111 An attempt to display the function that converts measurements in yards into meters
6
Functions
Some functions are too complex to express by algebraic fucntions sin(theta)
Can we find a system for computing fucntions regardless of the complexity
Noncomputable function = a function that cannot be computed by any algorithm
7
Turing Machines
Turing machine introduced by Alan M Turing in 1936 is conceptual device for studying the power of algorithmic processes1048708
It consists of a control unit that can read and write symbols on a tape by a RW head1048708
The tape extends indefinitely at both ends1048708Each cell on the tape can store any one of a finite set of symbolsndashalphabet1048708
At any time it must be in one of a finite number of states including starthalt states1048708
Its computation starts in the start state and ceases in the halt state
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
3
Theory of Computation
--Long before PCs were born there are theories developed to justify what machines can or cannot do
--Any problem that can be solved on a computer has a solution expressed in that corresponding language
--It can be concluded that there are some problems unsolvable by todayrsquos machines or any future algorithmic machine
4
Functions
Measurement of computation power if one machine is capable of computing more functions than another the former is considered the more powerful1048708
Table lookup method can substitute the functions for finite pairs of inputoutputrsquos1048708
Algebraic formulas are better ways to describe the inputoutput associations of many functions V=P(1+r)^n
5
Figure 111 An attempt to display the function that converts measurements in yards into meters
6
Functions
Some functions are too complex to express by algebraic fucntions sin(theta)
Can we find a system for computing fucntions regardless of the complexity
Noncomputable function = a function that cannot be computed by any algorithm
7
Turing Machines
Turing machine introduced by Alan M Turing in 1936 is conceptual device for studying the power of algorithmic processes1048708
It consists of a control unit that can read and write symbols on a tape by a RW head1048708
The tape extends indefinitely at both ends1048708Each cell on the tape can store any one of a finite set of symbolsndashalphabet1048708
At any time it must be in one of a finite number of states including starthalt states1048708
Its computation starts in the start state and ceases in the halt state
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
4
Functions
Measurement of computation power if one machine is capable of computing more functions than another the former is considered the more powerful1048708
Table lookup method can substitute the functions for finite pairs of inputoutputrsquos1048708
Algebraic formulas are better ways to describe the inputoutput associations of many functions V=P(1+r)^n
5
Figure 111 An attempt to display the function that converts measurements in yards into meters
6
Functions
Some functions are too complex to express by algebraic fucntions sin(theta)
Can we find a system for computing fucntions regardless of the complexity
Noncomputable function = a function that cannot be computed by any algorithm
7
Turing Machines
Turing machine introduced by Alan M Turing in 1936 is conceptual device for studying the power of algorithmic processes1048708
It consists of a control unit that can read and write symbols on a tape by a RW head1048708
The tape extends indefinitely at both ends1048708Each cell on the tape can store any one of a finite set of symbolsndashalphabet1048708
At any time it must be in one of a finite number of states including starthalt states1048708
Its computation starts in the start state and ceases in the halt state
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
5
Figure 111 An attempt to display the function that converts measurements in yards into meters
6
Functions
Some functions are too complex to express by algebraic fucntions sin(theta)
Can we find a system for computing fucntions regardless of the complexity
Noncomputable function = a function that cannot be computed by any algorithm
7
Turing Machines
Turing machine introduced by Alan M Turing in 1936 is conceptual device for studying the power of algorithmic processes1048708
It consists of a control unit that can read and write symbols on a tape by a RW head1048708
The tape extends indefinitely at both ends1048708Each cell on the tape can store any one of a finite set of symbolsndashalphabet1048708
At any time it must be in one of a finite number of states including starthalt states1048708
Its computation starts in the start state and ceases in the halt state
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
6
Functions
Some functions are too complex to express by algebraic fucntions sin(theta)
Can we find a system for computing fucntions regardless of the complexity
Noncomputable function = a function that cannot be computed by any algorithm
7
Turing Machines
Turing machine introduced by Alan M Turing in 1936 is conceptual device for studying the power of algorithmic processes1048708
It consists of a control unit that can read and write symbols on a tape by a RW head1048708
The tape extends indefinitely at both ends1048708Each cell on the tape can store any one of a finite set of symbolsndashalphabet1048708
At any time it must be in one of a finite number of states including starthalt states1048708
Its computation starts in the start state and ceases in the halt state
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
7
Turing Machines
Turing machine introduced by Alan M Turing in 1936 is conceptual device for studying the power of algorithmic processes1048708
It consists of a control unit that can read and write symbols on a tape by a RW head1048708
The tape extends indefinitely at both ends1048708Each cell on the tape can store any one of a finite set of symbolsndashalphabet1048708
At any time it must be in one of a finite number of states including starthalt states1048708
Its computation starts in the start state and ceases in the halt state
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
8
Figure 112 The components of a Turing machine
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
9
Turing machine operation
Inputs at each step State Value at current tape position
Actions at each step Write a value at current tape position Move readwrite head Change state
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
10
Figure 113 A Turing machine for incrementing a value
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
11
Universal programming language
A function can be computed in this manner by a Turing machine is called Turing computable
Church-Turing thesis A Turing machine can compute any computable function
(By Alan Turing and Alonzo Church) Restatement any computable function is Turing
computable Not proven but generally accepted
Universal programming language = a language that can express a program to compute any computable function Examples ldquoBare Bonesrdquo and most popular
programming languages
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
12
The Bare Bones language
Bare Bones is a simple yet universal language A universal programming language is a language that
encompasses the power of algorithmic processes themselves
If a problem can be solved algorithmically an algorithm for solving the problem can be expressed in the language
If the problem can not be expressed in the language there is no such an algorithm to solve the problem
Problem hArralgorithm hArrlanguage hArrmachine
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
13
The Bare Bones language
Machines merely manipulates the bit patterns according to the instructions
The bare bones language can simply treat all variables as being of type ldquobit pattern of any lengthrdquo directly so it needs no data description statements defined
Variable names consist only of letters statements terminate each with a semicolon
Statements(3 Assign and 1 Control) clear name incr name decr name while name not 0 do hellip end
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
14
The Bare Bones language
ldquoclear Yrdquo assigns a string of zeros to a variable Y1048708 ldquoincrYrdquoincrements the value of a variable Y to be
the next larger integer1048708 ldquodecrYrdquodecrements Y to be the next smaller
integer but remains zero as it isStatements(Assign and Control)
Initialization of variables ldquoX = 3rdquo ldquoclear X incrX incrX incrXrdquo1048708
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
15
The Bare Bones language
1048708 ldquoclear Z while X not 0 do incrZ decrX endrdquo--Copy ldquoZ = Xrdquo(cause ldquoX = 0rdquo)
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
16
Figure 114 A Bare Bones program for computing X x Y(Destroying the X value)
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
17
Figure 115 A Bare Bones implementation of the instruction ldquocopy Today to Tomorrowrdquo
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
18
理髮師悖論在薩維爾村有一個理髮師他掛出了一塊招牌規定著「我給而且只給村民中不給自己刮鬍子的人刮鬍子」
於是有人就問他「你給不給自己刮鬍子呢」無論這個理髮師怎麼回答都會產生矛盾如果他不給自己刮鬍子那麼按照招牌他應該給自己刮鬍子如果他給自己刮鬍子按照招牌所言他只給村裡不給自己刮鬍子的人刮鬍子那麼他便不能給自己刮鬍子
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
19
假設有一個克里特人名字叫伊壁孟德然後伊壁孟德說了一句話「克里特人都是撒謊者」
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
20
ldquo 無窮倒退rdquo 雞與雞蛋到底先有哪個rdquo先有雞嗎
不它必須從雞蛋裡孵出來那先有雞蛋嗎不它必須由雞生下這類耳熟能詳的例子在邏輯學家之間稱為ldquo無窮倒退rdquo
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
21
A non-computable function --The halting problem
Paradox Ex1--The next statement is true--The previous statement is falseEx2The cook on a ship cooks for all those and
only those who do not cook for themselves
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
22
A non-computable function --The halting problem
Goumldel numbering Kurt Goumldel invented a scheme to assign a unique non-negative integer to each object (formulas proofs programs) in a collection1048708Any program written in Bare Bones is possibly associated with a unique integer1048708
This integer is programrsquos Goumldel number
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
23
The halting problem A program is self-terminating if it ultimately
terminates after being started with its first variable initialized to its Goumldel number and other variables being reset to 01048708
Any program is either self-terminating or it is not1048708
For instance the program ldquowhile X not 0 do incrX endrdquo 1048708
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
24
Figure 116 Testing a program for self-termination
The halting problem is to predict in advance if a program will terminate given the input Goumldel number(program)
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
25
The halting problemAn example of a non-computable function is to
output 1 or 0 according to whether the program in question is self-terminating given the input Goumldel number(program)1048708
The problem of computing this function is commonly referred to as the halting problem
Given any encoded version of a program return 1 if the program will eventually halt or 0 if the program will run forever
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
26
Figure 117 Proving the unsolvability of the halting program
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
27
某些科學家想讓計算機不工作來節省機器的壽命結果他們的辦法便是向計算機說ldquo你必須拒絕我現在給你編的語句因為我編的所有語句都是錯的rdquo沒想到計算機卻因此而不斷地重複工作直到耗盡它的壽命
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
28
Complexity of problems
Among solvable problems some problems appear easier than the others1048708
Big theta notation is used to classify the algorithms on their efficiencies according to their execution time1048708
The insertion sort algorithm is in the class Θ(n^2) the sequential search algorithm is in Θ(n) and the binary search algorithm is in Θ(log n)
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
29
Complexity of problems
Unfortunately finding a best solution or knowing it is the best is difficult
Time complexity = number of instruction executions required Unless otherwise noted ldquocomplexityrdquo means ldquotime
complexityrdquo As such the big O notation is often used to
address the complexity of problems If f(n) is a mathematical expression in n and a
problem can be solved by an algorithm in Θ(f(n)) the complexity of a problem is in O(f(n)) safely upper bounded by f(n)
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
30
Complexity of problems
The problem could have a better solution1048708
A problem is in class O(f(n)) if it can be solved by an algorithm in (f(n))
A problem is in class (f(n)) if the best algorithm to solve it is in class (f(n))
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
31
Figure 118 A procedure Merge Lists for merging two lists
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
32
Figure 119 The merge sort algorithm implemented as a procedure MergeSort
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
33
Figure 1110 The hierarchy of problems generated by the merge sort algorithm
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
34
Figure 1111 Graphs of the mathematical expression n lg n n lg n and n2
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
35
Class P
Polynomial problems are the problems in O(f(n)) where f(n) is either a polynomial itself or bound by a polynomial1048708
P is traditionally used to represent the collection of all polynomial problems1048708
The searching and sorting problems belong to P1048708 A problem in P can be solved in polynomial time the
problem has a polynomial time solution Class P = all problems in any class (f(n)) where f(n) is a
polynomial Intractable = all problems too complex to be solved
practically Most computer scientists consider all problems not in
class P to be intractable
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
36
Class NP
Class NP = all problems that can be solved in polynomial time by a nondeterministic algorithm in a class P Nondeterministic or deterministic May require ldquocreativity--Go to next intersection and turn either right
or left--Go to next intersection and turn either right
or left depending on what the person standing on the corner tells you what to do
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
37
Class NP
The traveling salesman problem find a path fromto home via n cities whose total length within a budget
--Not a polynomial problem Alternative approach Pick one of the possible paths and
computer its total distance If the distance lt= budget then declare success else nothing
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
38
Class NP
Class NP Nondeterministic algorithm = an
ldquoalgorithmrdquo whose steps may not be uniquely and completely determined by the process state
May require ldquocreativityrdquo NP-complete problems are the set of problems in
NP if a solution in P found for one problem in the set it can be converted into solutions for others
Whether the class NP is bigger than class P is currently unknown
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
39
Figure 1112 A graphic summation of the problem classification
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
40
Public key cryptography
Key = specially generated set of values used for encryption Public key used to encrypt messages Private key used to decrypt messages
RSA = a popular public key cryptographic algorithm(honor 3 inventors) Relies on the (presumed) intractability of
the problem of factoring large numbers
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
41
Public key cryptography
Math tells us if p and q are prime numbers and m in an integer between 0 and pq then for any positive integer k it satisfies the following
1=(m^(k(p-1)(q-1))) mod (pq) If p=3 q=5 m =4 k=1 n=pq=15 4^(24) mod 15=65536 mod 15 = 1
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
42
Encrypting the message 10111 Let integer e d n satisfies ed=k(p-1)(q-1)+1 and n = pq p=7 q=13 e=5 d=29 n=7x13529=145=2(7-1)(13-1)+1 Encrypting keys n = 91 and e = 5 10111two = 23ten
23e = 235 = 6436343 6436343 divide 91 has a remainder of 4 4ten = 100two
Therefore encrypted version of 10111 is 100
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
43
Decrypting the message 100 Decrypting keys d = 29 n = 91 100two = 4ten
4d = 429 = 288230376151711744 288230376151711744 divide 91 has
a remainder of 23 23ten = 10111two
Therefore decrypted version of 100 is 10111
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
44
Figure 1113 Public key cryptography
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
45
Figure 1114 Establishing a RSA public key encryption system
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
46
Road map to CS study
Fundamental courses Physics Mathematics and Introduction to Computer Science
Software --Fundamental Problem Solving and Programming
Data Structure Algorithm and Software Engineering
--Language Assembly Language Programming Language CC++ and JAVA1048708
--Theory Software Methodology Formal Language amp Theory of Computation1048708
--System Architecture OS Compiler Networking Database and Multimedia
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics
47
Road map to CS study
Hardware1048708Electronics Logic Design VLSI
Design amp Digital System Design Applications1048708Consumer products
Numerical and Symbolic Computation Databases and Information Retrieval Artificial Intelligence and Robotics Graphics Organizational Informatics Bioinformatics