109 年 國立中正大學通訊工程學系碩士班通訊乙組《線性代數與資料結構》
第 1 題
Let
a. (10 pts.) Use Gaussian-Jordan elimination to find the reduced row echelon form of .
b. (10 pts.) Find the basis of column space of .
c. (10 pts.) Express the vector as a linear combination of the row vectors in , and find the coordinate vector with the basis .
登入後即可作答並保存紀錄。
核心觀念
本題考查以下線性代數概念:
- Gaussian–Jordan elimination:將矩陣化為 reduced row echelon form(RREF)。
- Column space 的基底:原矩陣中對應於 RREF 主元欄的欄向量,構成 的一組基底。
- Row space 的線性組合:向量若能表示成 的列向量線性組合,必須屬於 。
- 座標向量:若 是 的基底,則 僅在 時有定義。
解題方法
(a)求 的 reduced row echelon form
原矩陣為
先以第一列消去第一欄:
得到
交換第二列與第三列:
並以第二列消去第二欄:
將第三列除以 :
再消去第四欄:
最後消去第一列與第二列的第二欄、第四欄:
因此
主元欄為第 欄,故
(b)求 column space 的基底
基底必須取自原矩陣 的主元欄,不能直接取 RREF 的欄向量。
原矩陣的第 欄分別為
所以
因此
第 2 題
Let
a. (10 pts.) Find the null space of and determine the dimension of this null space.
b. (10 pts.) Find the eigenvalues and eigenvectors of .
登入後即可作答並保存紀錄。
核心觀念
本題考查:
- 齊次線性方程組 的解集合,即矩陣 的零空間。
- 零空間的維度,也就是 nullity。
- 特徵值與特徵向量的定義:
等價於
因此特徵值必須滿足:
a. 零空間與其維度
令
要求 :
得到方程組:
由第二式可得:
由第一式可得:
代入第三式:
因此:
所以只有零向量:
因此零空間為平凡零空間,其維度為:
也可由行列式判斷:
故 可逆,nullity 為 。
b. 特徵值與特徵向量
求特徵值
計算特徵方程:
其中
沿著第二列或第二行展開:
因此:
展開括號內的部分:
所以特徵方程為:
先由第一因子得到:
再解二次方程:
故三個特徵值為:
求 的特徵向量
代入 :
因此:
第 3 題
Consider a Binary Search Tree (BST) and answer the following questions.
a. (5 pts.) Whether Fig. 1 is a BST or not? If not, explain why it is not a BST.
b. (5 pts.) Define a data structure for a node in a BST.
c. (10 pts.) Using C or pseudocode to write a function to perform in-order traversal. Your function takes a BST with node structure defined in (b).
d. (10 pts.) Using C or pseudocode to write a function to insert a node to a BST. The input parameters of your function include the given BST and the given node for insertion.
🖼️【此處有附圖,請對照原卷】
登入後即可作答並保存紀錄。
核心觀念
二元搜尋樹(BST)的每個節點都必須符合:
- 左子樹的所有鍵值都小於該節點的鍵值。
- 右子樹的所有鍵值都大於該節點的鍵值。
- 左、右子樹本身也都必須是 BST。
判斷時要檢查整個子樹的值域限制,不能只比較父節點與直接子節點。
解題方法
(a) 判斷 Fig. 1 是否為 BST
圖中的根節點為 。左子樹的節點為 ,都小於 ;右子樹的節點為 ,都大於 。
以 為根的左子樹中,;以 為根的右子樹中,。各節點都符合 BST 的大小限制,因此 Fig. 1 是 BST。
也可用中序走訪快速驗證。BST 的中序走訪結果應為遞增序列;此圖的結果為:
(b) BST 節點結構
每個節點包含鍵值、左子節點指標與右子節點指標:
typedef struct Node {
int key;
struct Node *left;
struct Node *right;
} Node;
(c) 中序走訪
中序走訪的順序是「左子樹、根節點、右子樹」。對 BST 執行中序走訪時,會依鍵值由小到大輸出。
void inorder(Node *root) {
if (root == NULL)
return;
inorder(root->left);
printf("%d ", root->key);
inorder(root->right);
}
(d) 插入節點
第 4 題
Consider an undirected graph and answer the following questions.
a. (5 pts.) Find and draw a minimum spanning tree for the graph shown in Fig. 2.
b. (5 pts.) Define an adjacency matrix using C or pseudocode. Show the content of your matrix using the graph shown in Fig. 2.
c. (10 pts.) Using C or pseudocode to implement a function that takes an adjacency matrix defined in (b) to obtain a minimum spanning tree. You can also use more parameters for your function, such as the number of nodes in the graph. You can also limit the maximum number of nodes in the graph.
🖼️【此處有附圖,請對照原卷】
登入後即可作答並保存紀錄。
核心觀念
這題考無向加權圖的最小生成樹(Minimum Spanning Tree, MST)、加權鄰接矩陣,以及用程式找出 MST。
生成樹必須連接圖中的所有頂點,且不能有環;若圖有 個頂點,生成樹恰有 條邊。最小生成樹是在所有生成樹中,總邊權重最小者。
本題採用 Kruskal 演算法:將邊依權重由小到大排序,逐一加入;若加入某邊會形成環,就略過。使用並查集判斷兩端頂點是否已連通。
(a) 最小生成樹
由圖可讀出頂點為 ,各邊及權重如下:
| 邊 | 權重 |
|---|---|
| 2 | |
| 2 | |
| 3 | |
| 3 | |
| 3 | |
| 5 | |
| 5 | |
| 6 | |
| 9 |
依權重由小到大檢查:
- 加入 ,權重 。
- 加入 ,權重 。
- 加入 ,權重 ,連接頂點 與 。
- 加入 ,權重 ,連接 與 。
- 加入 ,權重 ,將頂點 接入。此時已選滿 條邊。
所得最小生成樹可表示為:
1 --(2)-- 2 --(3)-- 0
|
(3)
|
3
/ \
(2) (3)
/ \
4 5
總權重為:
(b) 加權鄰接矩陣
以下依頂點順序 排列。矩陣元素表示兩頂點間的邊權重;沒有邊時以 表示。由於本圖所有邊權重皆為正數, 不會與有效邊權重混淆。
(c) 以 Kruskal 演算法取得最小生成樹
先從矩陣取出所有無向邊,只讀取 的位置,避免重複記錄同一條邊。排序後,用並查集檢查每條邊的兩端是否已在同一集合;若不在同一集合,就加入 MST 並合併集合。