2017S1
Problem 1
A language over a finite alphabet is said to be regular if there exists a finite automaton such that . Here
Answer the following questions.
- We fix an alphabet by . For the language below, present a nondeterministic finite automaton (NFA) such that: , and the number of states of is not greater than 4.
-
Assume that is a finite alphabet. Prove the following: any finite language is regular. Here is a nonnegative integer.
-
We fix an alphabet by . For the language in Question (1), present a deterministic finite automaton (DFA) such that: , and the number of states of is not greater than 5. Here denotes the complement of in .
-
Give a decision procedure for the following problem, and explain it briefly.
Input: nondeterministic finite automaton .
Output: whether the language is an infinite set or not.
一个语言 在有限字母表 上,如果存在一个有限自动机 使得 ,则称该语言是正则的。这里
回答以下问题。
- 我们固定字母表 为 。对于以下语言 ,给出一个不超过 4 个状态的非确定性有限自动机 (NFA) ,使得:。
-
假设 是一个有限字母表。证明如下:任何有限语言 是正则的。这里 是一个非负整数。
-
我们固定字母表 为 。对于问题 (1) 中的语言 ,给出一个不超过 5 个状态的确定性有限自动机 (DFA) ,使得:。这里 表示 中 的补集。
-
给出以下问题的决策过程,并简要解释。
输入: 非确定性有限自动机 。
输出: 语言 是否是一个无限集。
Problem 2
Suppose that we are given an undirected graph where each edge is associated with a cost. A minimum spanning tree is a subgraph of the graph such that: it connects all the vertices; it is a tree; and it takes a minimum total cost. The following pseudo code (Algorithm ) shows an algorithm to compute a minimum spanning tree. We let the numbers of vertices and edges of be denoted by and , respectively.
Step 1. Choose an arbitrary vertex and let be the subtree of consisting of only that vertex.
Step 2. Choose an edge with a minimum cost, out of and add the edge and its end vertices to .
Step 3. Repeat Step 2 until contains all the vertices of .
Answer the following question.
- Answer an appropriate phrase that fills above.
There are multiple ways to implement Algorithm . Specifically, computation time differs depending on how to find an edge with a minimum cost in Step 2.
Answer the following questions.
-
Suppose that is dense () and given as an adjacency matrix. Explain a time-efficient implementation of Algorithm in this case. Answer also the time complexity of the implementation, and explain why.
-
Suppose that is sparse () and given as adjacency lists. Explain a time-efficient implementation of Algorithm in this case. Answer also the time complexity of the implementation, and explain why.
-
Show that the graph obtained using Algorithm is a minimum spanning tree of the graph .
假设我们有一个无向图 ,其中每条边都有一个成本。最小生成树是图的一个子图,它连接所有顶点;它是一棵树;并且它的总成本最低。以下伪代码(算法 )展示了一种计算最小生成树的算法。我们用 和 分别表示 的顶点数和边数。
步骤 1. 选择一个任意顶点,并让 为仅由该顶点组成的 的子树。
步骤 2. 从 中选择一条成本最小的边,并将该边及其终端顶点添加到 中。
步骤 3. 重复步骤 2,直到 包含 的所有顶点。
回答以下问题。
- 回答填充上文 处的适当短语。
有多种方法可以实现算法 。具体来说,在步骤 2 中找到成本最低的边的计算时间不同。
回答以下问题。
-
假设 是稠密的()并作为邻接矩阵给出。解释一种在这种情况下算法 的高效实现。还要回答实现的时间复杂度,并解释原因。
-
假设 是稀疏的()并作为邻接表给出。解释一种在这种情况下算法 的高效实现。还要回答实现的时间复杂度,并解释原因。
-
证明使用算法 获得的图 是图 的最小生成树。
Problem 3
Answer the following questions regarding sequential logic circuits. Assume that the clock is an ideal rectangular wave without skew, and that the gate delay is short enough compared with the clock cycle.
-
Choose one from D flip-flop, JK flip-flop and T flip-flop, and explain how its output is determined by the clock, the inputs and the internal state.
-
Design and depict a circuit ALT, whose output toggles between 0 and 1 every clock cycle as illustrated below. You can use the flip-flop you have chosen in Question (1), and the AND, OR and NOT gates.
Clock: ____|¯¯¯¯|____|¯¯¯¯|____|¯¯¯
Output of ALT: ____|¯¯¯¯¯¯¯¯¯|_________|¯¯¯¯¯¯
-
Design and depict a circuit that sorts 8 integers, each of which being a 4-bit unsigned integer, by the bubble sort algorithm. The inputs and the outputs of the sorting circuit are as follows:
- Inputs . Each of them is a 4-bit unsigned integer.
- 1-bit input .
- Outputs . Each of them is a 4-bit unsigned integer.
- 1-bit output .
The sorting circuit should work as follows.
(a) When is 1, the inputs are stored using 32 flip-flops. Those stored data are regarded as eight 4-bit unsigned integers, and called in the following.
(b) After becomes 0, in the first clock cycle, the circuit compares and , and if , then it swaps them, and otherwise it keeps them. The same operations are applied to the three pairs , and . The new values of are output to .
(c) In the second clock cycle after becomes 0, the circuit compares and , and if , then it swaps them, and otherwise it keeps them. The same operations are applied to the two pairs and . The new values of are output to .
(d) The circuit repeats steps (b) and (c) while is 0. If no swap of values happens for two consecutive clock cycles that execute (b) or (c), is set to 1, and otherwise is set to 0.
You can use the following circuits in your design: the flip-flop you have chosen in Question (1), the ALT circuit you have designed in Question (2), 4-bit comparator CMP, 4-bit 2-to-1 multiplexer MUX, and the AND, OR and NOT gates.
回答以下有关时序逻辑电路的问题。假设时钟是一个没有偏斜的理想矩形波,并且门延迟相对于时钟周期来说足够短。
-
从 D 触发器、JK 触发器和 T 触发器中选择一个,并解释其输出是如何由时钟、输入和内部状态决定的。
-
设计并描绘一个电路 ALT,其输出每个时钟周期在 0 和 1 之间切换,如下所示。你可以使用你在问题 (1) 中选择的触发器,以及 AND、OR 和 NOT 门。
Clock: ____|¯¯¯¯|____|¯¯¯¯|____|¯¯¯
Output of ALT: ____|¯¯¯¯¯¯¯¯¯|_________|¯¯¯¯¯¯
-
设计并描绘一个电路,使用冒泡排序算法对 8 个 4 位无符号整数进行排序。排序电路的输入和输出如下:
- 输入 。每个都是一个 4 位无符号整数。
- 1 位输入 。
- 输出 。每个都是一个 4 位无符号整数。
- 1 位输出 。
排序电路应如下工作。
(a) 当 为 1 时,输入 使用 32 个触发器存储。这些存储的数据被认为是八个 4 位无符号整数,并在下文中称为 。
(b) 变为 0 后,在第一个时钟周期中,电路比较 和 ,如果 ,则交换它们,否则保持不变。同样的操作应用于三对 , 和 。 的新值输出到 。
(c) 变为 0 后的第二个时钟周期中,电路比较 和 ,如果 ,则交换它们,否则保持不变。同样的操作应用于两对 和 。 的新值输出到 。
(d) 电路在 为 0 时重复步骤 (b) 和 (c)。如果在执行 (b) 或 (c) 的两个连续时钟周期内没有发生值交换,则 置为 1,否则 置为 0。
你可以在设计中使用以下电路:你在问题 (1) 中选择的触发器、你在问题 (2) 中设计的 ALT 电路、4 位比较器 CMP、4 位 2 比 1 多路复用器 MUX,以及 AND、OR 和 NOT 门。