목록전체 글 (431)
mojo's Blog
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/WXVeT/btrmyDWdpd6/NTZCdGRnMiymssxnFOhoB1/img.png)
Parameter Passing Parameter: actual parameter, formal parameter ● 실 매개변수와 형식 매개변수는 서로 값을 주고받는다 (parameter passing) ● 여러 가지 parameter passing 방법이 있음 ○ 참조 호출(Call by reference): 포트란77 ○ 값 호출 (Call by value): C 예시) a[i] = a[j] ● 산술식 a[j]는 값을 나타내는 r-값(right value) ● a[i]는 a[j]의 값이 있는 메모리의 위치인 l-value(left value, location value)을 나타낸다. ○ l-value: 산술식이 나타내는 기억 위치 ○ r-value: 메모리에 저장될 값 Call by Value 값 ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/2mmtQ/btrmgJj1kdY/Kb6oKR8PoX9jSoLzepLni0/img.png)
Concepts File : - byte 들의 단순한 선형적인 array로 정의된다. - inode number 로서 low-level 이름을 각 파일마다 가지고 있다. Directory : - 디렉토리도 파일이다. - A list of pairs. Interface : Creating a file O_CREAT flag을 사용하여 open system을 사용한다. int fd = open("foo", O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR); O_CREAT : 파일을 생성 O_WRONLY : 파일이 열릴 때, 오직 write 만을 허용 O_TRUNC : 파일 사이즈를 0으로 만듬 (그러나 기존에 있던 내용물이 제거됨) Interface : Reading a..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bzZ9sU/btrmgloydcc/XQ7mT1TAg6BMdgOgD0KHhK/img.png)
Structural data type 기본 자료형(elementary data type) ● 하나의 이름이 하나의 자료 객체(data object)를 가진 것 ● 정수, 실수, 문자형 등 구조적 자료형(structured data type) ● 하나의 이름에 여러 개의 자료 객체가 있는 것 ● 레코드, 배열, 문자열, 집합, 트리 등 ○ 레코드, 구조체: 이질(heterogeneous)의 자료 개체들을 하나로 묶고 이름을 부여하여 하나의 자료형을 선언 ○ PL/I, 코볼, 파스칼, C, 알골 등과 같은 언어는 레코드를 사용할 수 있는데 구체적 표현은 언어마다 조금씩 다르다. Record 레코드 ADDRESS ● PERSON, STREET, CITY와 같은 그룹 항목 ● 각 항목들은 다시 하나 이상의 기본..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bUTG3E/btrmbl9qMrK/YwpIKGps7WpZqGhIGxFhrk/img.png)
circuit sat Input: A Boolean circuit C Question: Is C satisfiable? Note that a Boolean circuit is a powerful enough model of computation to express any algorithm. We will show witness existence ≤ circuit sat implying circuit sat is NP-complete. We will convert an instance of (Π, x, t) of witness existence to a Boolean circuit C of polynomial size s.t. C is satisfiable if and only if there is a wit..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bqtyzE/btrl575VuIv/oTJb2Llcedjm2LRWYYEa31/img.png)
Problem – Let J = {1, 2, …, n} be a set of jobs to be served. – Each job takes one unit of time to finish. – Each job has a deadline and a profit. • If the job starts before or at its deadline, the profit is obtained. ➢ Schedule the jobs so as to maximize the total profit (not all jobs have to be scheduled). 예를 들어서 다음과 같은 Job(Deadline, Profit)이 4개 존재한다고 하자 이때, 최대 이익을 낼 수 있는 경우는 job = [4, 1] 인 경우..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/b0hla3/btrl1XitScJ/CUr2vWv3aP9L90mXBCRuv1/img.png)
Intermediate code는 ● semantic analysis 단계에서 만들어진 syntax tree를 이용하여 생성되거나, ● 문법 규칙이 reduce 될 때마다 syntax-directed translation으로 생성된다. ● intermediate code를 생성하는 데는 intermediate language를 사용한다. 컴파일러의 frontend와 backend를 연결해주는 기능을 한다. Intermediate Code 생성 방법 ● intermediate code generator (ICG)를 이용 ○ 파스 트리 또는 구문 트리를 순회하면서 효과적인 intermediate code를 생성 ● syntax-directed translation (SDT) 방법 ○ CFG의 각 생성 규칙에..