2022 Winter CS
Problem 1
For a matrix denoted by, we write for the submatrix formed from the rows through and the columns from through of the matrix. We also denote and by and, respectively. (Note that they are row and column vectors, respectively.)
Assume below that is an nonsingular matrix which can be LU factorized. In addition, assume that a positive integer exists such that all entries in the-th sub- and super-diagonal of are zero if. Namely, if is zero.
We denote the LU factorization of by, where is a lower triangular matrix with unit diagonal elements, and is an upper triangular matrix.
The following algorithm computes and from the input in-place in such a way that the strictly lower triangular part and the upper triangular part of will be and, respectively. In other words, will be for, and will be for, when it terminates.
Algorithm P
for(k=1 ; k<n ; k=k+1) {
}
Answer the following questions.
(1) Compute the LU factorization of the following matrix.
(2) Prove that and if.
(3) Assume that, and. We wish to solve a set of linear systems,
where are the constant vectors, and are the unknown vectors. Explain the relative merits of the following methods (I) and (II) with respect to the amount of arithmetic operations.
(I) Compute first, and then compute each as.
(II) Compute the LU factorization of first, and then solve for. Solve for lastly.
Problem 2
Let be a simple undirected graph with the vertex set and edge set. For an-dimensional vector, define by
Answer the following questions.
(1) For the case where is a complete graph of vertices, compute.
(2) Let and be those given in question (1). Let be the number of edges of. Compute.
(3) Let be an arbitrary simple undirected graph. When each takes a value of either or with probability independently, compute the expected value of. You may use the linearity of expectation.
(4) Show that, for any simple undirected graph, there exists some such that. Here, denotes the number of edges of.
Problem 3
Let. Answer the following questions.
(1) Give a non-deterministic finite state automaton with 3 states that accepts the following language.
(2) Show the minimal deterministic finite state automaton that accepts the language given in question (1).
(3) Prove that the following language over is not regular. You may use the pumping lemma for regular languages.
Here, denotes the reverse of. For example,.
(4) Is the language in question (3) a context-free language? If it is, construct a context-free grammar that generates. If not, prove that is not a context-free language.
Problem 4
Answer the following questions on digital circuits.
(1) Provide a Boolean expression of the output D according to the following truth table. Design and depict a corresponding combinational circuit by using at most six 2-input NAND gates.
Truth table
| Input | Output | ||
|---|---|---|---|
| A | B | C | D |
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
(2) Depict the internal structure of a D-flip-flop, and explain how the D-flip-flop holds a 1-bit value.
(3) Consider a clock-synchronous sequential circuit with a 1-bit input CLK, a 1-bit input, and a 1-bit output Y, where the input CLK is used for the clocking. The output Y is ‘1’ when the number of ’ 1 ’ in the input values in the past three clock cycles (excluding the current clock cycle) is greater than the number of ’ 0 '. Otherwise, the output is ’ 0 '. The output may be any value during the initial three clock cycles after the circuit is powered on. Assume that the circuit satisfies the setup-time and hold-time constraints. Design and depict the circuit. You may use at most two D-flip-flops and an arbitrary number of 2-input AND gates, 2-input OR gates, and NOT gates, if necessary.
2022 Summer CS
問题 1
オペレーティンク゚システムに関して以下の問いに答えよ.
(1) 5つのプロセス に対するスケジューリングについて, 各プロセス の到㖖 時間 と処理時間 をそれぞ と で表すすのとする. また, 同時に実行可能 なプロセスは 1 つのみで, コンテキストスイッチのオーバーへッドは無視できるものとする. である 場合に,5つのプロセスを Preemptive Shortest Job Firstアルゴリズムでスケジュールしたと きの平均ターンアラウンド時間と平均応答時間を求めよ. ここで, ターンアラウンド時間とは プロセスの到着から実行完了までの時間とし,応答時間とはプロセスの到着から実行開始まで の時間とする.
(2) 問い (1) と同じ到着時間と処理時間をもつ5つのプロセスを Non-Preemptive Shortest Job First アルゴリズム゙スケジュールしたときの平均ターンアラウンド時間と平均応答時間を求めよ.
(3) 問い (1) と同じ到着時間と処理時間をもつ5つのプロセスをタイムスライスが の Round Robin アルゴリズムでスケジュールしたときの平均ターンアラウンド時間と平均応答時間を求 めよ. プロセスがタイムスライスを使い切らなかった場合は即座に次のプロセスのタイムスラ イスが開始されるすのとする. また, 新たに到着したプロセスは Round Robin キューの末尾 に追加されるものとし, 桵数のプロセスが同時にキューの末尾に到着した場合には残りの処理 時間の短いプロセスの方が優先されて追加されるものとする.
(4) 現実のオペレーティングシステムてはコンテキストスイッチのオーバーヘッドは無視できない. このオーバーヘッドを考慮した場合, Round Robin アルゴリスムの利点と欠点について CPU スケジューリングとメモリ管理の観点から説明せよ.
(5) 現実のオペレーティングシステムではプロセス侁先度を決定するためにしばしば Aging 方式が 使われる. Aging 方式の基本概念と古典的な静的佽先度方式に対する優位性について説明せよ.
Problem 1
Answer the following questions on operating systems.
(1) For the scheduling of five processes, and, the arrival time (ms) and the computation time of each process are denoted by and, respectively. Also, assume that only one process is allowed to execute at any instant, and the overhead of context switches can be ignored. Obtain the average turnaround time and the average response time when the five processes are scheduled by the Preemptive Shortest Job First algorithm, where, and. Here, the turnaround time refers to the time interval from the arrival of the process to the completion of its execution, and the response time refers to the time interval from the arrival of the process to the beginning of its execution.
(2) Obtain the average turnaround time and the average response time when the five processes with the same arrival and computation times as those given in question (1) are scheduled by the Non-Preemptive Shortest Job First algorithm.
(3) Obtain the average turnaround time and the average response time when the five processes with the same arrival and computation times as those given in question (1) are scheduled by the Round Robin algorithm with the time slice. The next time slice starts immediately when the current process does not exhaust its time slice. Also, a new process is added to the end of the Round Robin queue upon its arrival, and ties are broken in favor of the processes with shorter remaining computation times if multiple processes arrive at the end of the queue simultaneously.
(4) In real-world operating systems, the overhead of context switches cannot be ignored. Explain the pros and cons of the Round Robin algorithm from the viewpoint of CPU scheduling and memory management, when this overhead is considered.
(5) The Aging scheme is often used to determine process priorities in real-world operating systems. Explain the basic concept of the Aging scheme and its advantage over the classical static-priority scheme.
問题 2
C言語で書かれた以下のプログラムは整数配列 aの a[i] から a[j-1] までを昇順に整列する関数 mysort(a,i,j) を定義している. プロクララム中の関数 multfrac(k,1,m) は が 正の整数であるとき 以上の最小の整数を求める関数であり,は正の整数定数とする. 整の数の演算はオーバーフローしないすのとする.
1 | int multfrac(int k, int l, int m){ |
以下の問いに答えよ.
(1)(w, x, y, z) が である場合, 空欄 に入れるべき適切なコードを答えよ. た だし, comparo_orap 以外の関数呼び出しは不可とする. なお,コードは複数行にわたっても 良い.
(2) mysort(a, 0, n) が呼び出された時にコード断片 が実行される回数の合㖕を と 表記する. が である場合, の に関するオーダーを与えよ.
(3) (w, x, y, z) が である場合のそれぞれについ て, mysort が常に正しく動作するか否かを答えよ.
(4)mysort が常に正しく動作するために w, が満たすべき必要十分条件を答えよ.
Problem 2
The following program written in C language defines a function mysort (a, i, j), which sorts an integer array a from a[i] to a[j-1] in ascending order (where ). The function multfrac (k, 1, m) used in the program returns the least integer that is greater than or equal to, when, 1 , and are positive integers. Assume that $\mathbf{w}, \mathbf{x}, \mathrm{y} $ and are positive integer constants. Assume also that integer operations never overflow.
1 | int multfrac(int k, int l, int m){ |
(1) Answer appropriate code to fill the blank when is. You are not allowed to use a function call except for compare_swap. The code may consist of multiple lines.
(2) Let denote the number of times that the code fragment is executed while mysort (a, 0, n) is called. Give the order of on when is.
(3) Answer whether or not mysort always works correctly for each case where is (4,, and.
(4) Give a necessary and sufficient condition on, and that guarantees mysort to always work correctly.
問题 3
とする. 語 について, の長さを と畵く.また, 空語(す なわち長さ0の語)を と茟く. 語 について, 関数 を以下のように定義する.
すなわち, は から, と一致する部分文字列の開始位䍛をたで置き換え, それ以外の位置 を で罩き換えて得られるものである. 例えば, である. さらに, 関数 を,以下の定義によって 上の言語を 上の言語に写像する関数 に拡張する.
例えば, である.
以下の問いに答えよ.
(1) (babababa) を求めよ.
(2) を正規表現を用いて表せ.
(3) 語 (ただし および決定性有限オートマトン ) が与えられた とし, が受理する言語を とする. ただし は, それぞれ の状態集合, 邉移関 数, 初期状態, 受理状培の集合を表すすのとし, 邉移関数 は全域関数である とする. を受理する非決定性有限オートマトンを, 䉍単な説明ととすに与えよ. 哄移 を用いてもよい.
(4) 以下の命題が真ならばその証明の概賂( を受理するプッシュダウンオートマトンまたは を生成する文脈自由文法を简単な説明とともに示せばよい)を, 偽ならば反例を示せ. 命頙 :「すべての語 について, が文脈自由言語ならば, も文脈自由言語 である」
Problem 3
Let and. For a word, we write for the length of. We also write for the empty word (i.e., the word of length 0). For a word, we define the function by:
In other words, is the word obtained from by replacing the start position of each subword that matches with and any other position with. For example, baaab fttff and abbab ttttt. Furthermore, we extend the function to the function that maps a language over to a language over by the following definition:
For example,.
Answer the following questions.
(1) Compute (babababa).
(2) Express by using a regular expression.
(3) Suppose that a word (where ) and a deterministic finite automaton are given, and that is the language accepted by. Here, are respectively the set of states, the transition function, the initial state, and the set of accepting states of. Assume that the transition function is total. Give a nondeterministic finite automaton that accepts, with a brief explanation. You may use-transitions.
(4) If the following proposition is true, then give a proof sketch (it suffices to show a pushdown automaton that accepts or a context-free grammar that generates, with a brief explanation). Otherwise, give a counterexample.
Proposition: “For every word, if is a context-free language, then is also a context-free language.”
問题 4
コンピュータアーキテクチャに関する以下の問いに答えよ.
(1) 命令 が生成する結果を命令 が利用する可能性がある場合に, 命令 に対する命令 のデタ 依存が存在するといい, と表す. 以下のプログラムに存在するデータ依存をすべて示せ. 各命令の動作はプログラム中のコメント(#以降の記述)の通りである. プログラムを実行す るプロセッサは x0 から x31 までの 32 個のレジスタを持ち, x0 は常に 0 を保持するゼロレジ スタとする. コメント中, メモリの addr 番地へのアクセスを “memory [addr]" と表す.
1 | 命令 0) addi x3, x0, 64 # x3 <- x0 + 64 |
(2) 每クロックサイクハ最大 1 命令を発行する, 5 段ステージのパイプラインプロセッサを考える. このプロセッサは, 命令フェッチ (IF) ステージ, 命令テコードとVジスタフェッチ (ID) ステー ジ, 実行 (EX) ステーシ, メモリアクセス (MA) ステージ, Vジスタ書き込み (WB) ステー ジの 5つのステージて棤成される. 各レジスタのピット幅は 32 である. 1 クロックサイクルて アクセス可能な命令メモリとデータメモリを持つすのとし, ロードワード命令 lw おびスト フワード命令 sw$ が MA ステージでストールすることはない. 命令 lw に関する被ロード・デー タハザードが発生する場合, IF ステージ, IDステージ,EXステージを1クロックサイクル するまで, IF ステージおよびID ステージをストールさせる. つまり, 分岐命令のフェッチ後, 2クロックサイクルの間, 後続の命令をフェッチしない,EXステージでの実行結果およびMA ステージでのロード結果は, EXステージに適切にフォワーデンングされるものとする.
被ロード・データハザードとは何かを説明せよ.また, このプロセッサ上て間い (1) のプログ ラムを実行する際に, 被ロード・゙゙ータハザードがとのように発生するかを説明せよ.
被ロード・データハザードとは何かを説明せよ. また, このプロセッサ上て問い (1) のプログ ラムを実行する際に,被ロード・データハザードがどのように発生するかを説明せよ.
(3) 問い (2) のプロセッサ上で, 問い (1) のプログラムを実行する際に要するクロックサイクル数 を求めよ. また, 平均 IPC (instructions per cycle) を小数第 2 位まで求めよ.
(4)問い (1) のプログラムおよび問い (2) のプロセッサを例に,動的分岐予測の原理と役割を説明 せよ.
Problem 4
Answer the following questions on computer architecture.
(1) When the instruction may use the result generated by the instruction, we say there is a data dependency from the instruction to the instruction, and write. Give all data dependencies in the program below. The behavior of each instruction is described as a comment (the description after #) in the program. The processor which executes the program has 32 registers from to, and is the zero register that always keeps the value 0 . In the comment, we represent a memory access to the address addr on the memory as “memory [addr]”.
1 | instruction 0) addi x3, x0, 64 # x3 <- x0 + 64 |
(2) Consider a 5-stage pipeline processor that issues up to one instruction per clock cycle. The processor consists of 5 stages: instruction fetch (IF) stage, instruction decode and register fetch (ID) stage, execution (EX) stage, memory access (MA) stage, and register write back (WB) stage. The bit width of each register is 32. The processor has the instruction and data memories that can be accessed in one clock cycle, and load-word lw and store-word sw instructions do not stall on the MA stage. If there is a load-use data hazard for lw instruction, the IF, ID, and EX stages are stalled for one clock cycle. The branch instruction blt (branch if less than) stalls the IF and ID stages until the branch result is determined in the EX stage. Thus, the processor does not fetch subsequent instructions for two clock cycles after a branch instruction is fetched. Execution results in the EX stage and load results in the MA stage are properly forwarded to the EX stage.
Explain what the load-use data hazard is. Explain also how load-use data hazards occur when the program in question (1) is executed on the processor.
(3) Calculate the number of clock cycles required for the execution of the program in question (1) on the processor in question (2). Calculate also the average IPC (instructions per cycle) up to two places of decimals.
(4) Using the program in question (1) and the processor in question (2) as an example, explain the mechanism and role of dynamic branch prediction.
2022 Math
問题1
以下の に関する複数の条件を考える.
を上記の条件を満たす が一つでも存在するような点 の集合とする. は三次元デ カルト座標系において上記の条件を満たすような点 の集合を 平面上に正射影し た図形とも解釈できる. 以下の問いに答えよ.
(1) を と に関する不等式で表現せよ.
(2) 集合 を 平面上に図示せよ. 図形の境界が 軸, 軸と交わる場合は, その交点 の座標も明記せよ.
(3) 集合 の境界の湾曲した区間は, 単位円の複数の円弧をある線形変換行列 で変換 した図形になっている. このような Xを一つ求めよ. ただし, 単位円上の点 は, 湾曲した区間の最も曲率の高い点に変換されなければならない.
(4) (3)で求めた X の行列式を求めよ.
(5)集合 の面積を求めよ. ただし, 図形を線形変換した場合の面積変化率は, その線形 変換行列の行列式の絶対值に等しいことを用いてもよい.
Problem 1
Consider the following multiple conditions on.
Let be the set of points for which at least one exists satisfying the above conditions. Note that the set can be seen in the three-dimensional Cartesian coordinate system as the orthogonal projection of points satisfying the above conditions onto the-plane. Answer the following questions.
(1) Find the inequalities on and representing.
(2) Draw a figure of in the-plane. If the boundary of intersects with the-axis or the-axis, write down the coordinates at each intersection.
(3) The curved segments of the boundary of correspond to the linear transformation of arcs of the unit circle with a matrix. Find one such. Note that the point on the unit circle must be transformed to a point where the curvature is maximized in the curved segments.
(4) Calculate the determinant of found in (3).
(5) Calculate the area of the set. Note that the absolute value of the determinant of a matrix is the area scale factor of the transformation with that matrix.
問题2
と に対し以下の積分 を考える.
ただし, 実数值関数 は において連続かつ微分可能で,導関数が連続であり, が成り立つと仮定する. 以下の問いに答えよ.
(1) とおく. であることを示せ. ここでは, 積分と微分が交換可能であることを用いてよい.
(2) とおく. 任意の に対して が存在し, かつ, これが 上一様収束することを示し,
であることを示せ.
(3) を求めよ.
(4) 以下の積分を求めよ. ただし, とする.
Problem 2
Consider the following integral for and.
Assume that a real-valued function is continuous and differentiable on, its derivative is continuous, and. Answer the following questions.
(1) Define. Show that.
You can use the fact that the integration and the differentiation commute in this context.
(2) Define. Show that exists for any and it uniformly converges on, and show that
(3) Obtain.
(4) Calculate the following integral. Note that.
問题3
平面上に, かつ で定義される領域 を考える. 上にランダムに 1 点を選び, それを点 とする. ただし, 点 は 上に一様に分布するとする. 図に表すよ うに, 点 から 軸への垂線を, 点 から 輣への垂線を とする. 原点を とした とき, 長有形 を「点 の長方形」と呼ぶ. また, 点 の長友形の面䅡を表す確率変 数を とする. 以下の問いに答えよ.
(1) の期待值を求めよ.
(2) となる確率を求めよ. ただし とする.
(3) の確率密度関数を求めよ.
再び, 領域 を考える. を正の整数とする. 上にランダムに 点を選び, それらを点 とする. ただし, 各点は 上に一梂に分布し, である と は独立 に選ばれるとする. 次の問いに答えよ.
(4) 点 の長方形の面積を表す確率変数を とする. を の最小值を表 す確率変数とする. この時, の確率密度関数を求めよ.

Problem 3
Consider a region defined by and in the-plane. We randomly select a point on and refer to the selected point as. We assume that is uniformly distributed on. Let be a perpendicular line from to the-axis and be a perpendicular line from A to the-axis as shown in the figure. We call rectangle OCAB as "the rectangle of ", where denotes the origin. Let be a random variable representing the area of the rectangle of. Answer the following questions.
(1) Calculate the expectation value of.
(2) Calculate the probability that holds, where.
(3) Calculate the probability density function of.
Again consider the region. Let be a positive integer. We select points on and refer to the selected points as. We assume that each of the points is uniformly distributed on, and and for are selected independently. Answer the following question.
(4) Let be a random variable representing the area of the rectangle of. Let be a random variable which is the minimum of. Calculate the probability density function of.





