U E D R , A S I H C RSS

TAOCP/Basic Concepts

1. 1.1 Algorithms


1.1. �고���� E(�������� �고����(Euclid's algorithm))

~cpp 
���� �� m과 n �������, 그����� ����(greatest common divisor)
(m과 n�� �� ������ ��� �� ���� ��)�� 구��.
E1. [�����기] m�� n���� ����고 ������ r�� ��.(0 <= r < n)
E2. [그� 0���?] r = 0 , �고���� ������; n ����.
E3. [��기] m <- n, n <- r ���� ����, 그��고 E1��계�� ���간��.■

~cpp 
Fig 1. �고���� E�� ������

        |<------------------------------------------------------|
       ↓                                                       |
--------------------          ------------------ ����   -------------
| E1.�����기 |-------->( E2.그� 0���? )-------->| E3.��기 |
--------------------          ------------------          -------------
                                        |��
                                       ↓

m = 119 n = 544 � ������고 ��
E1 ��계���� ����. m�� n���� ���� 0������ 119��. 그���� r <- 119
E2 ��계���� r ≠ 0 �� ������ ����
E3 ��계���� m <- 544, n <- 119
���� ������ m < n 이면 항상 m과 n이 교환된다는 것을 알 수 있다
������ ����과 � �� ��계�� ����� ����(꼭 ���� ��)

~cpp 
E0. [m >= n �� ���기] m < n ��, m <-> n �� 교��

E1���� ������ 544/119 = 4+68/119, 그���� r <- 68
���� E2�� �������고
E3���� m <- 119, n <- 68
���������� r <- 51, m <- 68, n <- 51
������ r <- 17, m <- 51, n <- 17
�������� 51�� 17�� ���������, r <- 0, 그러므로 E2에서 알고리즘은 종료된다
119 544�� ������ 17��


1.2. �고������ 5� ������

1) ����(Finiteness)
�고���� ����계 ���� ��������

2) ��(Definiteness)
�고������ 각 ��계�� �� ������

3) ����(Input)
�고���� 0개 �� ������ �����

4) ����(Output)
�고���� �� �� ������ �����

5) ������(Effectiveness)
�고���� �� ���������� ���������� 기����


1.3. �고������ 개���� ���� ������ ��� ��

������ ��(computational method)�� 4���� (Q,I,Ω,f)�� ���� 갖�� ����
Q�� ����� I �� ���� ����
f�� Q���� Q ��기�������� ��� ����
�� �� ���� q�� �� f(q)�� q��.
Q : 계��
I : ����
٠: ����
f : 계�� 규
��� I�� ���� x�� ��������, x0, x1, x2,..., �� ����과 � ����
~cpp 
	x0 = x	고	xk + 1 = f(xk) (k >= 0)
Ω�� ���� xk �� �� k��� �� �������� k��계���� ��������고 ��. 그��고 ���� x���� 결과 xk� ������고 ��.

�고���� E�� ����과 � �� ��� ������.
Q�� �� ���� (n), �� �������� �� (m,n), �� �������� 4�� (m,n,r,1), (m,n,r,2), (m,n,p,3) (m,n,p�� ���� ��, r �� �� ��)�� ���� ��.
I�� �� �� (m,n)�� ������ ��.
�� �� ���� (n)�� ������ ��.
f�� ����과 � ������.
~cpp 
f((m,n)) = (m,n,0,1};	f((n)) = (n);
f((m,n,r,1)) = (m, n, m�� n���� ���� ����, 2);
r = 0  f((m,n,r,2)) = (n), 그�� �� (m,n,r,3);
f((m,n,p,3)) = (n,p,p,1).

2. 1.3. MIX

���� ���� ������ MIX�� ������. ������ ������ ���� ���� 깊게 공��.

2.1. 1.3.1. Description of MIX

2.1.1. ����기

  • Words( Partitial fieslds of words���)
    ���� ������ ������. �������� 0~63까 ����� ���� ����. 그������ �� ����과 ���.
    0 1 2 3 4 5
    ± Byte Byte Byte Byte Byte
    �� �� ���� �� ����. �� (L:R)��. (L~R�� ������ ��.)
    <!> ��) (0:0)�� ��, (1:5)�� ��� ���� ����, (3:4)�� 3,4���� ����
  • Registers
    �������� �� ������ r�� �� ��기
    A, X register
    ± Byte Byte Byte Byte Byte
  • I register - rI1~rI6까 ����.
    ± Byte Byte
    J register
    + Byte Byte
    ��
    Overfolw toggle - on, off
    Comparison indicator, - EQUAL, LESS, GREATER
    Input, Output Devices
  • Instruction format
    0 1 2 3 4 5
    ± A A I F C
    C - �� ����(the poeration code)
    F - ���� 경(a modification of the operation code). (L:R)�� 8L+R = F
    ±AA - ���� ����(the address)
    I - ������(the index specification). 값 1~6���� rI1~rI6�� ���� ��과 ���� ������ ��
    ��기�� ���� ������ M, M�� ������ 값�� CONTETNS(M)��고 ��.
  • Notation
    ~cpp OP ADDRESS, I(F)
    ������ ��.
    <!> ''��) LDA�� �� ����� 8��.
    LDA 2000, 2(0:3) || + || 2000 |||| 2 || 3 || 8 || 과 ���.''

2.1.2. ����

  • Loading operators.
    CONTENTS(M)�� �������� ������.
    LDA, LDX, LDi, LDAN, LDXN, LDiN ����.
  • Storing operators.
    �������� 값�� CONTENTS(M)�� ������.
    STA, STX, STi, STJ, STZ� ����.
  • Arithmetic operators.
    �������� ��. ADD, SUB, MUL, DIV� ����.
  • Address transfer operators.
    �������� M ���� �� ����� �고, 그������ ������ ������. ENTr, ENNr, INCr, DECr ����. ( r A, X, 1~6)
    <!> ��) ENTA 2000 - > rA || + || 0 || 0 || 0 || 2000 ||
  • Comparison operator
    ������ CONTENTS(M)�� ��교�� LESS, GREATER, EQUAL�� ���� ����. CMPA, CMPX, CMPi ����. CMPi�� �� �� �� ����� 0��고 ���.
  • Jump operators.
    M������ ���� �� ������. JSJ�� �� ������ �� ���� �� ���� ������ rJ�� ����. the comparison indicator�� ���거��(JL, JE, JG, JGE, JLE, JNE) , ������(JrN, JrZ, JrP, JrNN, JrNZ, JrNP)�� ����.
  • Miscellaneous operators.
    ������ �� rA rX�� ������. SLA, SRA, SLAX, SRAX, SLC, SRC� ����. M �������� ������ ������.
    MOVE�� F���� CONTENTS(M)�� rI1������ ���� �� 값�� ������.
    <!> ''��1) rI1 = 1001�� � MOVE 1000,(3)
    CONTENTS(1000) -> CONTENTS(1001), rI1 = 1002
    CONTENTS(1001) -> CONTENTS(1002), rI1 = 1003
    CONTENTS(1002) -> CONTENTS(1003), rI1 = 1004''
    �� ������ ����?
    <!> ��2) rI1 = 2000�� � MOVE 1000,(3)
    ''CONTENTS(1000) -> CONTENTS(2000), rI1 = 2001
    CONTENTS(1001) -> CONTENTS(2001), rI1 = 2002
    CONTENTS(1002) -> CONTENTS(2002), rI1 = 2003''
    (rI1값 ��간��간 ����게 ���� �� ����고 F���� ������고 �각�� --���)
  • NOP �� �� ����.
    HLT �� 기계�� ������(The machine stops.)
  • Input-output opertors.
    ����고 ������.
  • Conversion operators.
    NUM rAX�� ������� ��꾸 rA�� ����. 각 ����� ������ ������, ���� ������ ���꾼��(10 -> 0, 23->3 )
    CHAR�� rA�� ����� ������ ��꾸 rAX�� ����.
  • Timing
    ���� ���� ��간(excution time) ����.

2.2. 1.3.3 Applications to Permutations

MIX ����그���� ������ ����. �������� ����(properties of permutations)�� ��개��.

�� abcdef�� ����(rearrangement)�� ����꾸기(renaming)�� �� ����고 �� �� ����. �� ����과 � ������ ����.(p.164����)
( a b c d e f )
( c d f b e a )
������(a cycle notation)�� �� ����과 ���
( a c f ) ( b d )
�� : a� c�� ���� �(a goes to c)�� a->c��고 ������. ������ ���� ���� a->c->f->a, b->d->b�� ������.e->e� �� � ����.

2.2.1. Products of permutations

�� ���� 곱��. (���� ������.)
(a b c d e f ) × (a b c d e f )
(c d f b e a ) (b d c a f e )
= (a b c d e f )
(c a e d f b )
�� a cycle notation���� ��
(a c f ) (b d )(a b d )(e f) = (a c e f b)
�� ������ �������� ��� ���� ������. a�� ���� a->c고, c���� ���� c->f->e�� ������ ���� �� ����. �� ������ ������.

2.2.2. Algorithm A

A1. �� � ����� ������ �����. ����� ����� � ��� ���� ������ ��꾸고 ������ �����.
��) (a c f g) -> (a c f g a
A2. ���� �������� ��� ���� ���� ������ ������ START��고 ��. � ��������� �����고 ������ �����. �� ������ ���� ���� 경�� ������.
A3. ���������� CURRENT�� ������.
A4. �������� ��� CURRENT ������ ������. ���� ������ ��기고 A3�� 간��. ( ��고 ������까 A5�� 간��.)
A5. START≠ CURRENT CURRENT�� �����고 �� �� ������ A4�� 간��.( ��� A6�� 간��.)
A6. (������ ������) ����� ����� ��고 A2�� 간��.
* Timing
�� ��.

2.2.3. Another Approach(Algorithm B)

What is this computer-oriented method for permutation multipulication?
�������� ���� ���� ���� ���� ����.
(��기���� ���� ���� Table2(p.173)�� ��. ���� �� Ti�� ������. 그 ���� i, j, Z 값�� �� ���� �� ����. n ������ 개����.)
B1. �� 1≤k≤n�� �� Tk ← k. ������ ���� ���� ��.
B2. ���� ������ ���� ������
) Z←0�고 B2����
( B4��.
���� i�� xi�� �고 B3��
B3. Z↔Ti�� �고 ���� Ti = 0 j←i�� �� B2��.
B4. Tj ← Z ���� B2��.
  • Timing
    ��������10�� ����.

2.2.4. Inverse

�� ������ ������ ������ ��(������과 ������.)
������ �� �� ��게 결( Y[Xk ← k )
�� ������� nㅣ ���� ��고 ���� ����� ����고 ��.

2.2.5. Algorithm I

(������ Table 3(p.177)�� �� ����.)

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:09
Processing time 0.0384 sec