Skip to content

Commit

Permalink
東京大学 情報理工学系研究科 コンピュータ科学専攻 2020年8月実施 専門科目 問題1~4
Browse files Browse the repository at this point in the history
  • Loading branch information
Myyura committed Feb 19, 2025
1 parent 51c144a commit 049bf19
Show file tree
Hide file tree
Showing 6 changed files with 541 additions and 0 deletions.
107 changes: 107 additions & 0 deletions docs/kakomonn/tokyo_university/IST/cs_202008_senmon_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
comments: false
title: 東京大学 情報理工学系研究科 コンピュータ科学専攻 2020年8月実施 専門科目 問題1
tags:
- Tokyo-University
- Graph-Theory
---
# 東京大学 情報理工学系研究科 コンピュータ科学専攻 2020年8月実施 専門科目 問題1

## **Author**
[zephyr](https://inshi-notes.zephyr-zdz.space/)

## **Description**
In undirected graphs, a self-loop is an edge connecting the same vertex, and multi-edges are multiple edges connecting the same pair of vertices. From now on, we consider undirected graphs without self-loops and possibly with multi-edges. We say that a graph $\mathbf{G}$ is an $\mathbf{A}$-graph if a graph consisting of a single edge can be obtained from $\mathbf{G}$ by repeatedly applying the following two operations.

### B-operation

When two multi-edges connect a pair of vertices, replace the multi-edges with a single edge connecting the pair of vertices.

### C-operation

When one edge connects vertices $\mathbf{u}$ and $\mathbf{v}$, another edge connects $\mathbf{v}$ and $\mathbf{w}$ (where $\mathbf{u} \neq \mathbf{w}$), and there is no other edge incident to $\mathbf{v}$, remove the vertex $\mathbf{v}$ and replace the two edges with a new edge connecting $\mathbf{u}$ and $\mathbf{w}$.

Answer the following questions.

(1) Let $\mathbf{K}_n$ be a complete graph of $\mathbf{n}$ vertices. Answer whether each of $\mathbf{K}_3$ and $\mathbf{K}_4$ is an $\mathbf{A}$-graph or not.

(2) Show that every $\mathbf{A}$-graph is planar.

(3) Give the maximum number of edges of an $\mathbf{A}$-graph with $\mathbf{n}$ vertices without multi-edges, with a proof. Also, give such an $\mathbf{A}$-graph attaining the maximum for general $\mathbf{n}$, with an explanation.

(4) Give an $\mathbf{O(m + n)}$-time algorithm which, given an undirected graph with $\mathbf{n}$ vertices and $\mathbf{m}$ edges as an input, determines whether it is an $\mathbf{A}$-graph or not. Explain also the graph data structures used in the algorithm for realizing $\mathbf{B}$-operations and $\mathbf{C}$-operations.

## **Kai**
### (1)

**$\mathbf{K}_3$:**
The complete graph $\mathbf{K}_3$ consists of 3 vertices and 3 edges, forming a triangle. Since there are no multi-edges in $\mathbf{K}_3$, the $\mathbf{B}$-operation does not apply. To apply the $\mathbf{C}$-operation, we need a vertex $\mathbf{v}$ with exactly two incident edges, connecting to vertices $\mathbf{u}$ and $\mathbf{w}$. In $\mathbf{K}_3$, each vertex is connected to two others, so we can apply the $\mathbf{C}$-operation to any vertex, forming an edge between the remaining two vertices, and applying the $\mathbf{C}$-operation again will reduce the graph to a single edge. Therefore, $\mathbf{K}_3$ is an $\mathbf{A}$-graph.

**$\mathbf{K}_4$:**
The complete graph $\mathbf{K}_4$ consists of 4 vertices and 6 edges, forming a tetrahedron. Similar to $\mathbf{K}_3$, there are no multi-edges, so the $\mathbf{B}$-operation does not apply. For the $\mathbf{C}$-operation, we need a vertex with exactly two incident edges. In $\mathbf{K}_4$, each vertex is connected to three others, so we cannot directly apply the $\mathbf{C}$-operation. Hence, $\mathbf{K}_4$ is not an $\mathbf{A}$-graph.

### (2)

Planar graphs are graphs that can be embedded in the plane without edge crossings.

Every $\mathbf{A}$-graph is planar. This can be shown by considering the operations allowed on $\mathbf{A}$-graphs:

- The $\mathbf{B}$-operation simplifies the graph by removing multi-edges, which does not affect planarity.
- The $\mathbf{C}$-operation reduces the number of vertices while maintaining planarity because it replaces a vertex of degree 2 with a single edge, which is a planar transformation.

Since a single edge is trivially planar and the operations preserve planarity, every $\mathbf{A}$-graph must be planar.

### (3)

The maximum number of edges in an $\mathbf{A}$-graph with $\mathbf{n}$ vertices without multi-edges is $\mathbf{n-1}$.

**Proof:**
- In an $\mathbf{A}$-graph, the $\mathbf{B}$-operation reduces multi-edges to a single edge, and there are no multi-edges in the final graph.
- The $\mathbf{C}$-operation reduces the number of vertices by 1 while maintaining the number of edges. Therefore, the number of edges in the final graph is $\mathbf{n-1}$.

### (4)

To determine if a given undirected graph with $\mathbf{n}$ vertices and $\mathbf{m}$ edges is an $\mathbf{A}$-graph, we can use the following algorithm:

1. **Graph Representation:** Use an adjacency list to store the graph. This allows efficient traversal and modification.
2. **Initialize:** Mark all vertices as unvisited.
3. **Identify and Apply $\mathbf{B}$-operation:**
- For each pair of vertices, check for multi-edges.
- If multi-edges exist, replace them with a single edge.
4. **Identify and Apply $\mathbf{C}$-operation:**
- Traverse the graph to identify vertices of degree 2.
- For each vertex $\mathbf{v}$ with degree 2 connecting vertices $\mathbf{u}$ and $\mathbf{w}$, remove $\mathbf{v}$ and replace edges $\mathbf{(u,v)}$ and $\mathbf{(v,w)}$ with a single edge $\mathbf{(u,w)}$.
5. **Repeat Steps 3 and 4** until no more $\mathbf{B}$ or $\mathbf{C}$ operations can be applied.
6. **Check Result:** If the graph reduces to a single edge, it is an $\mathbf{A}$-graph. Otherwise, it is not.

**Graph Data Structures:**
- **Adjacency List:** Efficiently stores the graph and allows for quick traversal and edge modification.
- **Degree List:** Maintains the degree of each vertex for quick identification of vertices suitable for the $\mathbf{C}$-operation.

The algorithm runs in $\mathbf{O(m + n)}$ time since each edge and vertex is processed a constant number of times.

## **Knowledge**

图论 平面图 算法

### 难点解题思路

识别和应用 $\mathbf{B}$ 和 $\mathbf{C}$ 操作是确定 $\mathbf{A}$-图的关键。对于复杂图的处理,可以通过维护邻接表和度列表来优化操作。

### 解题技巧和信息

对于确定图的性质问题,特别是涉及特定操作的图,可以通过模拟操作并逐步简化图结构来判断。理解操作对图结构的影响是关键。

### 重点词汇

- Self-loop 自环
- Multi-edges 多重边
- Planar 平面
- Complete graph 完全图
- Algorithm 算法

### 参考资料

1. "Introduction to Graph Theory" by Douglas B. West, Chapter 4
2. "Graph Theory" by Reinhard Diestel, Chapter 5

121 changes: 121 additions & 0 deletions docs/kakomonn/tokyo_university/IST/cs_202008_senmon_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
comments: false
title: 東京大学 情報理工学系研究科 コンピュータ科学専攻 2020年8月実施 専門科目 問題2
tags:
- Tokyo-University
---
# 東京大学 情報理工学系研究科 コンピュータ科学専攻 2020年8月実施 専門科目 問題2

## **Author**
[zephyr](https://inshi-notes.zephyr-zdz.space/)

## **Description**
Let $\Sigma$ be the set $\{a, b\}$ of letters. For a word $w \in \Sigma^*$ and two languages $L_a, L_b \subseteq \Sigma^*$ over $\Sigma$, we define the language $w\{a \mapsto L_a, b \mapsto L_b\} \subseteq \Sigma^*$ as follows, by induction on $w$.

$$
\epsilon\{a \mapsto L_a, b \mapsto L_b\} = \{\epsilon\}
$$

$$
(aw)\{a \mapsto L_a, b \mapsto L_b\} = \{w_1 w_2 \mid w_1 \in L_a, w_2 \in w\{a \mapsto L_a, b \mapsto L_b\}\}
$$

$$
(bw)\{a \mapsto L_a, b \mapsto L_b\} = \{w_1 w_2 \mid w_1 \in L_b, w_2 \in w\{a \mapsto L_a, b \mapsto L_b\}\}
$$

Here, $\epsilon$ represents the empty word. For example, if $w = aba$, $L_a = \{b^n \mid n \geq 0\}$, and $L_b = \{a^n \mid n \geq 0\}$, then $w\{a \mapsto L_a, b \mapsto L_b\} = \{b^l a^m b^n \mid l, m, n \geq 0\}$. Furthermore, for languages $L, L_a, L_b \subseteq \Sigma^*$, we define $L\{a \mapsto L_a, b \mapsto L_b\}$ as $\bigcup_{w \in L} w\{a \mapsto L_a, b \mapsto L_b\}$. For example, if $L = \{a^n b \mid n \geq 0\}$, $L_a = \{ab\}$, and $L_b = \{a^n \mid n \geq 0\}$, then $L\{a \mapsto L_a, b \mapsto L_b\} = \{(ab)^m a^n \mid m, n \geq 0\}$.

Answer the following questions.

(1) Let $L = \{(ab)^m a^n \mid m, n \geq 0\}$, $L_a = \{bb\}$, and $L_b = \{ab, a\}$. Express $L\{a \mapsto L_a, b \mapsto L_b\}$ using a regular expression.

(2) Let $L' = \{a^m b^n \mid m \geq n \geq 0\}$, $L_a' = \{a^n \mid n \geq 0\}$, and $L_b' = \{a^m b^m \mid m \geq 0\}$. Express $\{w \in \Sigma^* \mid w\{a \mapsto L_a', b \mapsto L_b'\} \subseteq L'\}$ using a regular expression.

(3) Let $A_0 = (Q_0, \Sigma, \delta_0, q_{0,0}, F_0)$, $A_1 = (Q_1, \Sigma, \delta_1, q_{1,0}, F_1)$, and $A_2 = (Q_2, \Sigma, \delta_2, q_{2,0}, F_2)$ be deterministic finite automata, and for each $i \in \{0, 1, 2\}$, let $L_i$ be the language accepted by $A_i$. Here, $Q_i, \delta_i, q_{i,0}, F_i$ are the set of states, the transition function, the initial state, and the set of final states of $A_i$ ($i \in \{0, 1, 2\}$), respectively. Assume that the transition functions $\delta_i \in Q_i \times \Sigma \rightarrow Q_i$ ($i \in \{0, 1, 2\}$) are total. Give a non-deterministic finite automaton that accepts $L_0 \{a \mapsto L_1, b \mapsto L_2\}$, with a brief explanation. You may use $\epsilon$-transitions.

(4) For $A_i$ and $L_i$ ($i \in \{0, 1, 2\}$) in question (3), give a deterministic finite automaton that accepts $\{w \in \Sigma^* \mid w\{a \mapsto L_1, b \mapsto L_2\} \subseteq L_0\}$, with a brief explanation.

## **Kai**
### (1)

Given $L = \{(ab)^m a^n \mid m, n \geq 0\}$, $L_a = \{bb\}$, and $L_b = \{ab, a\}$:

$$
L\{a \mapsto L_a, b \mapsto L_b\} = (bb(ab+a))^*(bb)^*
$$

This expression represents the language where every $a$ in the original language is replaced by $bb$ and every $b$ is replaced by either $ab$ or $a$.

### (2)

Given $L' = \{a^m b^n \mid m \geq n \geq 0\}$, $L_a' = \{a^n \mid n \geq 0\}$, and $L_b' = \{a^m b^m \mid m \geq 0\}$, for $w \in \Sigma^*$, suppose $w' = w\{a \mapsto L_a', b \mapsto L_b'\}$.

Since $w' \subseteq L'$, we can express any element of $w'$, $w'_i$ as $a^x a^y b^y$ where $x, y \geq 0$. This implies that $w'$ contains $a^x$ followed by $a^y b^y$ for some $x, y \geq 0$.

Since all of the $b$ in $w'_i$ can only come from $b$ in $w$, we can reverse the substitution process to get $w = a^x b^y$, where $y$ can only be $0$ or $1$.

Therefore, the regular expression for $\{w \in \Sigma^* \mid w\{a \mapsto L_a', b \mapsto L_b'\} \subseteq L'\}$ is:

$$
a^*(\epsilon + b)
$$

### (3)

We will construct an NFA that accepts $L_0 \{a \mapsto L_1, b \mapsto L_2\}$ using $\epsilon$-transitions. The NFA will have the same structure as $A_0$, but the transitions will be replaced based on the input letter with the transitions from $A_1$ and $A_2$, and $\epsilon$-transitions will be used to connect the states.

For example, supposing the original transitions for the input letter $a$ in $A_0$ are $q_{0,0} \xrightarrow{a} q_{0,1}$, we will replace these transitions with the corresponding transitions from $A_1$:

$$
q_{0,0} \xrightarrow{\epsilon} q_{1,0} \xrightarrow{} \ldots \xrightarrow{} F_{1,i} \xrightarrow{\epsilon} q_{0,1}
$$

Similarly, for the input letter $b$, we will replace the transitions with the corresponding transitions from $A_2$.

The final states of the NFA will be those states where the original final states of $A_0$ are reached after the substitution process.

**Explanation:** Since the language $L_0 \{a \mapsto L_1, b \mapsto L_2\}$ is obtained by substituting the strings in $L_1$ and $L_2$ for $a$ and $b$ in the strings of $L_0$, the NFA needs to simulate this substitution process by transitioning to the corresponding states in $A_1$ and $A_2$ based on the input letter.

### (4)

To construct a DFA for $\{w \in \Sigma^* \mid w\{a \mapsto L_i, b \mapsto L_j\} \subseteq L_k\}$:

**Explanation:**
- We need to track the states of $A_i$, $A_j$, and $A_k$ simultaneously.
- The DFA will have states $(q_i, q_j, q_k)$, where $q_i \in Q_i$, $q_j \in Q_j$, and $q_k \in Q_k$.
- The initial state is $(q_{i0}, q_{j0}, q_{k0})$.
- The transition function will be defined as:
- $(q_i, q_j, q_k) \xrightarrow{a} (\delta_i(q_i, a), q_j, \delta_k(q_k, w_{L_i}))$ for all $w_{L_i} \in L_i$.
- $(q_i, q_j, q_k) \xrightarrow{b} (q_i, \delta_j(q_j, b), \delta_k(q_k, w_{L_j}))$ for all $w_{L_j} \in L_j$.
- The final states are those where the third component is a final state in $F_k$.

This DFA ensures that as we read $w$, we keep track of the corresponding states in $A_i$, $A_j$, and $A_k$ to ensure the substitution process results in strings that belong to $L_k$.

## **Knowledge**

语言替换 正则表达式 NFA DFA

### 难点解题思路

1. 语言替换的正则表达式表达形式,需要理解替换过程以及结果语言的模式。
2. 识别满足特定替换条件的字符串集合,需要考虑原语言和替换后的语言的关系。
3. 构造非确定性有限自动机 (NFA) 以处理语言替换,需要使用 $\epsilon$-transitions 连接不同自动机的状态。
4. 构造确定性有限自动机 (DFA) 来接受满足条件的字符串集合,需要同时跟踪多个自动机的状态。

### 解题技巧和信息

- 在处理语言替换问题时,理解每一步替换过程对最终结果的影响非常重要。
- 构造 NFA 和 DFA 时,注意状态之间的转换关系以及如何利用 $\epsilon$-transitions 连接不同语言的自动机。

### 重点词汇

- $\epsilon$-transitions: $\epsilon$-转换
- Regular Expression: 正则表达式
- Non-deterministic Finite Automaton (NFA): 非确定性有限自动机
- Deterministic Finite Automaton (DFA): 确定性有限自动机

### 参考资料

1. Michael Sipser, "Introduction to the Theory of Computation", Chapter 2
2. John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman, "Introduction to Automata Theory, Languages, and Computation", Chapter 3
Loading

0 comments on commit 049bf19

Please sign in to comment.