basis and practice in programming lecture notes (2/19)
TRANSCRIPT
고려대학교정보보호대학원
마스터제목스타일편집
고려대학교정보보호대학원
Computer Program vs. Algorithm
고려대학교정보보호대학원
마스터제목스타일편집
2
Who am I?
고려대학교정보보호대학원
마스터제목스타일편집
고려대학교정보보호대학원
마스터제목스타일편집CyKor @ DEFCON CTF 2015(Advisor : Seungjoo Kim)
고려대학교정보보호대학원
마스터제목스타일편집
(Founder & Board Member : Seungjoo Kim, 2011)
(사)HARU & SECUINSIDE
고려대학교정보보호대학원
마스터제목스타일편집
6
Program vs. Algorithm
고려대학교정보보호대학원
마스터제목스타일편집
7
Algorithm : the step-by-step procedure for solving the problem.
Program : the implementation in “code” that instructs the computer how to execute the algorithm.
Note : the algorithm could be done by a person instead of a computer. This is actually often a good way of designing an algorithm: solve the problem repetitively and observe what procedure you follow.
Algorithm (Design) vs. Programming
고려대학교정보보호대학원
마스터제목스타일편집
8
1) Recognize and clarify a problem to solve.2) Devise a method for solving it AND3) Implement the solution, simultaneously.
(NO!)4) Test, correct and revise the method as
needed.
Step 2 is MUCH harder if you're trying to do step 3 at the same time. This is probably because step 3 is infinitely harder if you haven't finished step 2.
How to make algorithm design and programming MUCH harder
고려대학교정보보호대학원
마스터제목스타일편집
9
1) Recognize and clarify a problem to solve.
2) Devise a method for solving it (first).
3) Implement the solution (after step 2).
4) Test, correct and revise the method as needed.
Keep the steps separate.
How to make algorithm design and programming MUCH easier
고려대학교정보보호대학원
마스터제목스타일편집
10
More advice on algorithm design
Identify the input data.
Identify the output data.
Identify the mathematical relationships between the two.
Think about the “mechanical” steps you'd go through to produce the output from the input.
Write it on paper as a flow chart or “pseudocode” before trying to code.
고려대학교정보보호대학원
마스터제목스타일편집
11
Writing pseudocode
English
Pseudocode
Real programming languages
Increasing precision
Ease of expression
Describe the ideas of an algorithm in English.
Use pseudocode to clarify sufficiently tricky details of the algorithm.
Textbook use PASCAL-like or C-like pseudocode.
고려대학교정보보호대학원
마스터제목스타일편집
12
Algorithm vs. Problem
고려대학교정보보호대학원
마스터제목스타일편집
13
Algorithm : the step-by-step procedure for solving the problem.
Program : the implementation in “code” that instructs the computer how to execute the algorithm.
Program vs. Algorithm
고려대학교정보보호대학원
마스터제목스타일편집
14
Decidable (Solvable) :
Feasible (Tractable) : A problem that has a worst-case polynomial-time algorithm
Infeasible (Intractable) : A problem that DOES NOT have a worst-case polynomial-time algorithm
Undecidable (Unsolvable) : A problem that has NO algorithms at all
Algorithm vs. Problem
예) 1024비트이상의합성수 N
고려대학교정보보호대학원
마스터제목스타일편집
15
Q) What problems can TM solve?
A) Not all problems can be solved. An undecidable problem is one that cannot be solved by any algorithm, even given unbounded time and memory. Many undecidable problems are known. For example,
The halting problem is :
Given a program and inputs for it, decide whether the program will run forever or will eventually halt, given that input. Alan Turing proved in 1936 that a general algorithm to solve the halting problem for all possible program-input pairs cannot exist. We say that the halting problem is undecidable over Turing machines.
Undecidable Problem
고려대학교정보보호대학원
마스터제목스타일편집
16
Theory of Computational Complexity started in 1965 by Hartmanis and Stearns; expanded on by Blum, Cook, and Karp.
Key notions : polynomial-time reductions, NP-completeness.
Complexity Theory
고려대학교정보보호대학원
마스터제목스타일편집
17
Goal : A general theory of the resources needed to solve computational problems.
What types of resources?
Time, Space, Energy
What types of computational problems?
Composing a poem, Optimization
Sorting a database, Decision problem
Complexity Theory
고려대학교정보보호대학원
마스터제목스타일편집
18
P vs. NP
고려대학교정보보호대학원
마스터제목스타일편집
19
P : Can be solved on a DTM in an amount of time that is polynomial in the size of the input.
NP : Solutions can be verified in polynomial time, or equivalently, whose solution can be found in polynomial time on a NDTM.
Open question : P = NP ? 클레이수학연구소의 21세기 7대 백만불짜리문제 중의 하나
Need to define NPC(NP-complete).
P vs. NP vs. NPC
고려대학교정보보호대학원
마스터제목스타일편집
20
P vs. NP vs. NPC
2N
N10
N3
N2
N
Polynomial-time
Exponential-time
N
T(N)
고려대학교정보보호대학원
마스터제목스타일편집
21
NPC : The most difficult problems in NP, in the sense that they are the ones most likely NOT to be in P.
If you could find a way to solve AN NPC problem quickly (= in polynomial time), then you could use that algorithm to solve ALL NP problems quickly.
P vs. NP vs. NPC
고려대학교정보보호대학원
마스터제목스타일편집
22
P : p × q × r × s × t = N
(e.g.) 9,419 × 1,933 = 18,206,927
NP : N = p × q × r × s × t
(e.g.) 18,206,927 = 9,419 × 1,933
(e.g.) IFP
고려대학교정보보호대학원
마스터제목스타일편집
23
(e.g.) DLP
P
NP
gₗ= Y
(예) 10 = 10,000,000,000 : = 10
gₗ mod p = Y
(예) 10 mod 19 = 9 : = 10
고려대학교정보보호대학원
마스터제목스타일편집
24
QRP : Decide whether or not a is a quadratic residue modulo n
SQROOT : Find x satisfying x2 a mod n
DHP : Find αab mod p from αa mod p and αb mod p
SUBSET-SUM : Given a set of positive integers {α1, α2, …, αn} and a positive integer s, determine whether or not there is a subset of the αj that sums to s.
기타암호학관련 NP 문제들
고려대학교정보보호대학원
마스터제목스타일편집
고려대학교정보보호대학원
Computer Program vs. Algorithm