115 年 國立成功大學資訊工程系碩士班《計算機數學》
Consider all simple (loop-free), undirected graphs on a set of distinct labeled vertices . Every edge connects two distinct vertices, and multiple edges are not allowed. Assume that no vertex is isolated (i.e., every vertex has degree at least ).
第 1-(a) 題10 分
How many such graphs have exactly one connected component (i.e., the graph is connected)?
登入後即可作答並保存紀錄。
核心觀念
連通圖中每個頂點都至少與一條邊相接,因此「圖連通」已經保證沒有孤立點。題目等同於計算 個標號頂點上的連通簡單無向圖數。
對 個標號頂點,簡單無向圖總數為 :每一對不同頂點之間的邊都可選擇存在或不存在。接著用遞迴扣除不連通的圖。
解題方法
令 表示 個標號頂點上的連通圖數。固定一個頂點,依它所在連通分量的頂點數 分類。不連通時,,故
其中, 是選出包含固定頂點的 個頂點的方法數;這些頂點之間須形成連通圖,有 種;其餘 個頂點之間的邊則任意選擇,有 種。
第 1-(b) 題10 分
How many such graphs have exactly two connected components?
登入後即可作答並保存紀錄。
核心觀念
圖恰有兩個連通分量,表示頂點集合可分成兩個互不相交的部分,且每一部分誘導出的子圖都必須連通。又因為沒有孤立點,每個連通分量至少有 個頂點。
解題方法
將 個頂點分成兩個大小都至少為 的連通分量,唯一可行的大小分配是 。
先從 個標記頂點中選出屬於二頂點分量的兩個頂點:
這兩個頂點要形成連通分量,彼此之間必須有一條邊,因此只有 種接法。
第 2 題10 分
A network engineer is designing a fault-tolerant routing backbone for a data-center fabric. The backbone consists of routers, arranged physically in a cylindrical grid. There are horizontal layers (“rings”), each containing routers. Horizontally, each layer forms a -router cycle (i.e., the leftmost and rightmost routers are connected). Vertically, each of the columns also forms a -router cycle (i.e., the top and bottom switches are connected). Thus, every router has degree : two connections within its horizontal ring, and two within its vertical ring.
Determine whether this cylindrical multi-ring backbone can be embedded on a flat PCB without wiring intersections. Justify your answer using only Euler’s formula and girth-based edge bounds. In graph theory, the girth of an undirected graph is the length of the shortest cycle contained in the graph.
登入後即可作答並保存紀錄。
核心觀念
本題用平面圖的歐拉公式與「最短環長度(girth)」導出的邊數上界,判斷網路圖能否平面嵌入。若圖有 個頂點、 條邊,且每個面的邊界長度至少為 ,則平面圖必須滿足
解題方法
先計算頂點數、邊數與 girth,再代入平面圖邊數上界。
題目給出 層、每層 個路由器,因此頂點數為
每個路由器的度數都是 。由握手定理,度數總和等於邊數的兩倍:
圖中沒有長度為 的環:每一步只會改變所在層或所在欄;若三步都改變同一座標,必須在該座標的環上形成三角形,但 與 都沒有三角形;若分散在兩個座標,至少一個座標只移動一步,無法回到起點。
A self-organizing ad-hoc satellite network consists of multiple satellites placed at arbitrary integer coordinates in 3-dimensional space. Each satellite is modeled as a point . A secure communication link may be established between satellites and only if the midpoint of the segment also lies on an integer lattice point. Equivalently, all three coordinate-wise averages must be integers:
第 3-(a) 題10 分
The Space Agency wants to guarantee that even without knowing the positions of the satellites beforehand, there must exist at least one secure link.
Determine the smallest integer such that, no matter how the satellites are placed in , there is always at least one pair whose midpoint is a lattice point (i.e., at least one secure link always exists).
登入後即可作答並保存紀錄。
核心觀念
兩點的中點是整數格點,等價於兩點在每個座標上的奇偶性都相同。也就是說,若
、,則必須有
每個座標只有奇、偶兩種奇偶性,因此三維空間共有 種奇偶組合,可視為 8 個奇偶類別。
解題方法
將每顆衛星依其座標的奇偶性分類。若兩顆衛星落在同一類別,三個座標各自同奇偶,兩座標相加皆為偶數,因此其中點的三個座標都是整數,兩顆衛星之間便有安全鏈路。
第 3-(b) 題10 分
Now modify the secure-link condition. A link is allowed if the total coordinate sum of the two satellites is even, i.e.,
Under this new rule, determine the new minimum number of satellites guaranteeing that at least one secure link must exist.
登入後即可作答並保存紀錄。
核心觀念
將每顆衛星的三個座標和對 取餘數,分成兩類:
- 偶類:
- 奇類:
新連線條件可改寫為
兩個整數的和為偶數,表示它們同奇偶。因此,兩顆衛星能建立安全連線,恰好在它們的座標總和同奇偶時成立。
解題方法
第 4 題10 分
Consider the recurrence:
with initial values . Estimate the smallest such that .
登入後即可作答並保存紀錄。
核心觀念
這題考二階線性常係數非齊次遞迴。先解特徵方程,再依右側的指數項找特解。當非齊次項 對應的底數 是特徵根,且重根次數為 時,特解須乘上 。
解題方法
先解齊次遞迴
特徵方程為
因此齊次解為 。
對 項,因 是二重特徵根,設特解為 。將 代入遞迴左側,可得
取 時,括號內的二階差分為 ,故 。
對 項,設特解為 。代入左側得
令其等於 ,得到 。因此通解為
You are designing the firmware logic for a high-security electronic lock. The lock receives a stream of binary signals ( or ) from a keypad. Draw the state transition diagrams for two different versions of the security protocol. Use the Moore Machine model for both versions. Specifically, use circles to represent states with labels where is the index starting from , use arrows to represent transitions, use an arrow to point to the start state, and mark the "Unlock" state as double circles.
第 5-(a) 題10 分
The Standard "Header-Trailer" Protocol Specification:
- Start-up Check: When the system first turns on, it must check for a specific "Header." The very first two signals received must be a followed by another .
- Security Violation: If the first two signals are anything other than a pair of s, the system detects a hack. It must immediately enter a Permanent Lockout state where it ignores all future input and never unlocks.
- Monitoring: Once the valid header () is received, the system waits. It ignores the specific pattern of the signals in the middle.
- Unlocking: The door should unlock if and only if the last two signals received were a followed by another .
- Relocking: If the system receives more signals after unlocking that break the "00" ending, the door must lock again and go back to monitoring for a new "00" ending.
登入後即可作答並保存紀錄。
核心觀念
本題考查 Moore Machine(摩爾機):輸出由目前所在狀態決定,而不是由「狀態與輸入」共同決定。因此,解鎖狀態要以一個專屬狀態表示,並標示為雙圓。
設計狀態時,追蹤兩件事:
- 開機後是否已依序收到標頭 ;若前兩個訊號不符合,就進入永久鎖定狀態。
- 標頭通過後,追蹤目前連續收到幾個 。連續收到兩個 時解鎖;收到 會中斷結尾的 ,回到監控狀態。
解題方法
各狀態定義如下:
- :起始狀態,尚未收到訊號。
- :第一個訊號是 ,等待第二個訊號。
- :永久鎖定狀態,忽略後續輸入。
- :標頭 已通過,最近訊號不是 ,目前沒有連續結尾 。
- :標頭已通過,最近剛收到一個 。
- :標頭已通過,最近收到至少兩個連續 ,輸出「解鎖」。
轉移如下:
- 收到 轉到 ;收到 轉到 。
- 收到 ,標頭成立,轉到 ;收到 ,轉到 。
- 對 、 都留在 。
- 收到 留在 ;收到 轉到 。
- 收到 轉到解鎖狀態 ;收到 回到 。
- 收到 留在 ,因為結尾仍是 ;收到 回到 ,等待新的 結尾。
第 5-(b) 題10 分
The Advanced "Strict Rhythm" Protocol Specification:
We request a security update to the logic designed in (a). Modify your Finite State Machine to incorporate the following three specific changes. All other behaviors (like the "11" start-up check) remain the same.
- Enforce Alternating Data: Instead of ignoring the signals between the header and the unlock command, the system must now strictly enforce an alternating "0, 1, 0, 1, ..." pattern.
- Immediate Lockout on Error: If this alternating rhythm is broken (for example, if two s appear consecutively after the header), the system must immediately enter the Permanent Lockout state.
- One-Time Access: The "Relock" feature is removed. Once the door unlocks (upon receiving the "00" suffix), any further input signals are considered a security violation and must trigger the Permanent Lockout state.
登入後即可作答並保存紀錄。
核心觀念
Moore 機的輸出只由目前狀態決定,所以「解鎖」要是一個獨立狀態(雙圓)。本小題在 (a) 的基礎上改三件事:
- 標頭
11之後的資料必須嚴格交替0,1,0,1,…; - 節奏一被打破就立刻進入永久鎖定;
- 取消重新上鎖:解鎖後再收到任何訊號都視為違規,進入永久鎖定。
其餘行為與 (a) 相同——前兩個訊號必須是 11,否則永久鎖定。
解題方法
狀態定義:
| 狀態 | 意義 | 輸出 |
|---|---|---|
| 起始,尚未收到訊號 | 鎖定 | |
收到標頭第一個 1 | 鎖定 | |
標頭 11 完成,等待交替資料的 0 | 鎖定 | |
最近收到交替序列中的 0(下一個應為 1,或再一個 0 構成解鎖命令) | 鎖定 | |
最近收到交替序列中的 1,下一個必須是 0 | 鎖定 | |
| 解鎖(雙圓) | 解鎖 | |
| 永久鎖定(吸收狀態) | 鎖定 |
轉移表:
| 目前狀態 | 輸入 0 | 輸入 1 |
|---|---|---|
| (起始) | ||
By factoring into , the LU decomposition allows solving by first solving , followed by , each requiring only a single triangular solve. Thus, computing is crucial in large-scale computer engineering applications.
Algorithm 1. LU Decomposition Without Pivoting
Require: Matrix
Ensure: Lower triangular matrix , upper triangular matrix such that
- Initialize .
- For to do:
- For to do:
- End for.
- For to do:
- End for.
- For to do:
- End for.
- Return .
Algorithm 2. Speed-Improved Block LU Decomposition
Require: Matrix , where is a power of
Ensure: Matrices with
- Function :
- Let size of .
- If , then return .
- Partition into blocks:
- .
- .
- .
- .
- .
- Construct:
- Return .
- End function.
Algorithm 3.
- If , then return .
- Partition into blocks:
- If :
- Else:
- Return .
- End function.
Algorithm 4.
- If , then return .
- Partition into blocks:
- Compute:
- Compute:
- Return .
- End function.
第 6-(a) 題10 分
Give the complexity of the classic LU decomposition shown in Algorithm 1.
登入後即可作答並保存紀錄。
核心觀念
本題考查經典 分解的時間複雜度。演算法依序計算 的上三角元素與 的下三角元素;每個元素的計算都包含一段長度隨目前列數增加的求和,因此總運算量需將各階段的求和次數加總。
解題方法與推導
固定第 輪:
- 對每個 計算一次,內積包含 項,共有 個元素。
- 對每個 計算一次,內積同樣包含 項,共有 個元素。
因此,所有內積的乘積項數為
第 6-(b) 題10 分
An improvement of (a) based on the block matrix multiplication is shown in Algorithm 2. Give the complexity of the speed-improved LU decomposition.
登入後即可作答並保存紀錄。
核心觀念
Algorithm 2 以分塊方式計算 LU 分解,並用 Algorithm 4 的 Strassen 矩陣乘法加速主要矩陣運算。令
Strassen 乘法每層只遞迴計算 個大小為 的乘法,另花 做矩陣加減,因此其時間滿足
解題方法
先分析分塊三角求解 SISolve。每次遞迴將問題分成兩個大小為 的三角求解,並執行一次矩陣乘法及矩陣加減,所以
代入 ,得
再分析 LU 分解。大小為 的問題會遞迴分解左上角區塊與 Schur complement,各一次;另外進行兩次三角求解、一次 Strassen 矩陣乘法,以及區塊加減。
第 6-(c) 題10 分
Given
compute the LU decomposition using the speed-improved LU decomposition method in (b). List the key intermediate results from Algorithm 2 to receive full credit.
登入後即可作答並保存紀錄。
核心觀念
分塊 LU 分解將矩陣寫成
比較區塊可得
而右下角區塊由 Schur 補數給出:
本題的矩陣大小為 ,分塊後各區塊都是純量,因此遞迴呼叫都會直接使用純量基底情況。
解題方法與中間結果
將題目矩陣分成四個純量區塊:
1. 分解左上區塊
依演算法 2 第 5 步,對 呼叫遞迴。純量基底情況回傳:
2. 計算右上區塊
演算法 2 第 6 步呼叫下三角解法:
因此
3. 計算左下區塊
演算法 2 第 7 步呼叫上三角解法:
因此
Let with , and assume that is rank-deficient, i.e., . is positive semi-definite.
第 7-(a) 題10 分
Let . Show that the matrix is positive definite.
登入後即可作答並保存紀錄。
核心觀念
對稱矩陣 正定的定義是:對每個非零向量 ,都有 。本題利用
以及 ,證明加上 後,二次型對所有非零向量皆嚴格大於零。
解題方法
令 為任意非零向量。計算矩陣 的二次型:
第 7-(b) 題10 分
Derive the closed-form solution for
登入後即可作答並保存紀錄。
核心觀念
這題考的是正則化最小平方法(ridge regression)。目標函數由殘差平方和 ,加上懲罰項 組成;其中 用來抑制解的大小。
由於 欠秩, 是半正定矩陣,單靠最小平方法未必能得到唯一解。加入 後,矩陣 會成為正定矩陣,因此目標函數有唯一的全域最小值。
解題方法
將目標函數寫成
展開後,
對 求梯度:
令梯度為零,得到正則化常態方程: