115 年 國立中山大學資訊管理學系碩士班甲組《計算機概論》
第 1 題5 分
- Which of the following best describes the characteristics of packet switching?
(A) A dedicated connection must be established before data transmission
(B) All packets follow the same transmission path
(C) Each packet can be routed independently
(D) No routers are required in the network
登入後即可作答並保存紀錄。
本題考驗封包交換 (packet switching) 的基本特性。封包交換是一種網路通訊技術,其中資料被分割成較小的單元(封包),並獨立地路由到目的地。
(A) 錯誤。封包交換與電路交換 (circuit switching) 不同,電路交換在資料傳輸前需要建立一條專用的通訊電路。封包交換則不需要預先建立專用路徑。
(B) 錯誤。
第 2 題5 分
- Which of the following protocols is NOT an application-layer protocol?
(A) HTTP
(B) ARP
(C) SMTP
(D) DNS
登入後即可作答並保存紀錄。
本題考驗網路協定分層模型(例如 TCP/IP 或 OSI 模型)中各協定的層級歸屬。應用層協定是直接與使用者應用程式互動的協定。
(A) HTTP (Hypertext Transfer Protocol) 是應用層協定,用於網頁瀏覽。
第 3 題5 分
- During the TCP three-way handshake, which of the following statements is correct?
(A) The second packet has both the SYN and ACK flags set
(B) The client acknowledges the server's sequence number in the first packet
(C) The primary purpose of the three-way handshake is flow control
(D) UDP uses the same handshake procedure
登入後即可作答並保存紀錄。
本題考驗 TCP 的三次握手 (three-way handshake) 機制。三次握手是建立 TCP 連線的過程,確保雙方都準備好進行資料傳輸。
TCP 三次握手的流程如下:
- Client to Server: Client 發送 SYN (Synchronize) 封包給 Server。此封包包含 Client 的初始序號 (Initial Sequence Number, ISN)。
- Server to Client: Server 收到 SYN 封包後,若同意建立連線,則回傳 SYN-ACK (Synchronize-Acknowledge) 封包給 Client。此封包包含 Server 的 ISN,同時也 ACK (Acknowledge) 了 Client 的 ISN。
第 4 題5 分
- Which of the following is NOT a necessary condition for a deadlock to occur?
(A) Mutual exclusion
(B) Hold and wait
(C) With preemption
(D) Circular wait
登入後即可作答並保存紀錄。
本題考驗死鎖 (deadlock) 發生的必要條件。死鎖是指兩個或多個進程在執行過程中,因爭奪資源而造成的一種互相等待的現象,若無外力作用,它們都將無法繼續執行。
死鎖發生的四個必要條件(Coffman conditions)是:
- 互斥 (Mutual Exclusion): 至少有一種資源必須是不能被共享的,一次只能被一個進程使用。
- 持有並等待 (Hold and Wait): 進程至少持有一個資源,並等待取得其他進程所持有的資源。
第 5 題5 分
- In a virtual memory system, when a page fault occurs, which of the following actions is NOT
necessarily performed?
(A) Loading the page into main memory
(B) Updating the page table
(C) Triggering an operating system interrupt
(D) Performing page replacement
登入後即可作答並保存紀錄。
本題考驗虛擬記憶體系統中發生頁面錯誤 (page fault) 時的處理流程。頁面錯誤發生時,表示 CPU 嘗試存取的虛擬記憶體頁面不在主記憶體中。
當發生頁面錯誤時,作業系統通常會執行以下步驟:
- 觸發頁面錯誤中斷 (Trigger an operating system interrupt): CPU 偵測到無效的記憶體存取(因為頁面不在記憶體中),會產生一個硬體中斷,將控制權交給作業系統的頁面錯誤處理程序。
- 定位所需的頁面 (Locate the required page): 作業系統根據頁面錯誤資訊,在磁碟(或其他二級儲存)上找到所需的頁面。
- 為頁面分配一個主記憶體框 (Allocate a frame in main memory): 作業系統需要找到一個空閒的主記憶體框來載入該頁面。
- 頁面置換 (Performing page replacement): 如果沒有空閒的記憶體框,作業系統必須選擇一個目前在記憶體中的頁面,將其寫回磁碟(如果被修改過),然後將其移除,以便為新的頁面騰出空間。
第 6 題5 分
- Which of the following best describes pass-by-reference?
(A) Passing the value of a variable
(B) Passing the address of a variable
(C) Passing the data type of a variable
(D) Passing a copy of a variable
登入後即可作答並保存紀錄。
本題考驗程式語言中參數傳遞的機制,特別是「傳址呼叫」(pass-by-reference)。
- 傳值呼叫 (Pass-by-value): 函數接收的是變數的「值」的副本。在函數內部對參數的修改不會影響到函數外部的原始變數。
- 傳址呼叫 (Pass-by-reference): 函數接收的是變數的「位址」。在函數內部對參數的修改會直接影響到函數外部的原始變數,因為函數操作的是原始變數所在的記憶體位置。
- 傳名呼叫 (Pass-by-name): 參數在函數內部被替換成參數的表達式。
第 7 題5 分
- Which of the following systems is most suitable for using a NoSQL database rather than a relational
database?
(A) Core banking transaction systems
(B) Social media user activity data
(C) Payroll management systems
(D) Accounting general ledger systems
登入後即可作答並保存紀錄。
本題考驗 NoSQL 資料庫與關聯式資料庫 (Relational Database) 的適用場景。
- 關聯式資料庫 (RDBMS): 強調結構化資料、預定義綱 (schema)、ACID 交易特性 (Atomicity, Consistency, Isolation, Durability),適合需要高度一致性、完整性和複雜查詢的應用,如金融交易、會計系統。
- NoSQL 資料庫: 設計上更靈活,通常不強制嚴格綱,擅長處理大量非結構化或半結構化資料,並提供高擴展性 (scalability) 和可用性 (availability)。常見類型有鍵值 (key-value)、文件 (document)、寬欄 (wide-column)、圖形 (graph) 資料庫。
分析選項:
(A) Core banking transaction systems: 核心銀行交易系統需要極高的資料一致性、原子性交易和嚴格的 ACID 特性,這是關聯式資料庫的強項。NoSQL 在此類場景下較難滿足嚴格的交易要求。
第 8 題5 分
- Which of the following scenarios is most suitable for using multithreading rather than
multiprocessing?
(A) Tasks that frequently share data and require fast context switching
(B) Tasks that require strong isolation and high security
(C) Tasks that require parallel computation across multiple machines
(D) Systems that must avoid any synchronization mechanisms
登入後即可作答並保存紀錄。
本題考驗多執行緒 (multithreading) 與多程序 (multiprocessing) 的適用場景。
- 多執行緒 (Multithreading): 在同一個程序內,有多個執行緒 (thread) 可以並行執行。執行緒共享程序的記憶體空間和資源。
- 優點: 建立與切換開銷較小,適合處理 I/O 密集型任務或需要頻繁共享資料的任務。
- 缺點: 由於共享記憶體,需要額外的同步機制來避免資料競爭,執行緒之間的隔離性較差。
- 多程序 (Multiprocessing): 系統中有多個獨立的程序(進程,process)可以同時執行。每個程序都有自己的獨立記憶體空間和資源。
- 優點: 程序之間的隔離性好,一個程序的崩潰不會影響其他程序,適合 CPU 密集型任務或需要高安全隔離的任務。
- 缺點: 建立與切換開銷較大,程序間通訊 (IPC) 較複雜。
分析選項:
(A) Tasks that frequently share data and require fast context switching:
第 9 題5 分
- Which of the following statements most accurately describes Big-O notation in time complexity
analysis?
(A) Big-O describes the average-case running time for all inputs
(B) Big-O provides the exact upper bound of actual execution time
(C) Big-O applies only to recursive algorithms
(D) Big-O ignores constants and lower-order terms to describe the asymptotic upper bound
登入後即可作答並保存紀錄。
本題考驗時間複雜度分析中的大 O 符號 (Big-O notation) 的定義與意義。
大 O 符號用於描述演算法執行時間(或空間)與輸入規模 之間的漸進關係。它關注的是當輸入規模趨於無窮大時,執行時間的增長趨勢。
分析選項:
(A) Big-O describes the average-case running time for all inputs: 錯誤。大 O 符號主要描述的是最壞情況下的時間複雜度 (worst-case time complexity),雖然也可以用來描述平均情況或最好情況,但預設情況下是指最壞情況。
(B) Big-O provides the exact upper bound of actual execution time: 錯誤。大 O 符號提供的是一個漸進的上界,它忽略了常數因子和低階項。它不是精確的執行時間,而是執行時間的增長趨勢。
第 10 題5 分
- In object-oriented programming, which of the following statements about polymorphism is most
accurate?
(A) Polymorphism occurs only at compile time and is unrelated to runtime behavior
(B) Polymorphism allows the actual method to be determined at runtime
(C) Polymorphism is equivalent to method overloading
(D) The purpose of polymorphism is to improve program execution performance
登入後即可作答並保存紀錄。
本題考驗物件導向程式設計 (Object-Oriented Programming, OOP) 中的多型 (Polymorphism) 概念。
多型 (Polymorphism) 是物件導向的三大特性之一(繼承、封裝、多型)。它的意思是「多種形態」。在 OOP 中,多型允許我們以統一的介面來處理不同類型的物件。
分析選項:
(A) Polymorphism occurs only at compile time and is unrelated to runtime behavior: 錯誤。雖然有些多型的形式(如方法重載)在編譯時就確定,但物件導向中最具代表性的多型(如方法覆載,method overriding,透過繼承和介面實現的動態綁定)是在執行時期才確定實際要呼叫的方法。
(B) Polymorphism allows the actual method to be determined at runtime: 正確。這是動態多型 (dynamic polymorphism) 的核心。
第 11 題5 分
Question Group 1 (15%, each 5%)
Consider the following C program fragment, and answer question 11 to 13. Some parts are intentionally omitted.
int* process(int n) {
int *arr = (int*) malloc(n * sizeof(int));
if (arr == NULL) return NULL;
for (int i = 0; i < n; i++) {
arr[i] = i * 2;
}
// Missing statement A: ensure arr can store one extra int
arr[n] = -1;
return arr;
}
int main() {
int *p = process(5);
// Missing statement B
printf("%d\n", *p);
free(p);
return 0;
}
- Which option is the best completion for statement A to ensure correctness and avoid unnecessary overhead?
(A)
int *tmp = (int*)realloc(arr, (n + 1) * sizeof(int));
if (tmp == NULL) { free(arr); return NULL; }
arr = tmp;
(B)
arr = (int*)realloc(arr, (n + 1) * sizeof(int));
(C)
int *tmp = (int*)malloc((n + 1) * sizeof(int));
for (int i = 0; i < n; i++) tmp[i] = arr[i];
arr = tmp;
(D)
arr = (int*)realloc(arr, (n + 1) * sizeof(int*));
登入後即可作答並保存紀錄。
核心觀念
原先配置的陣列有 個 int,合法索引範圍是 到 。程式接著要執行 arr[n] = -1,因此陣列必須至少能容納 個 int。
realloc 可調整既有配置區塊的大小。若調整失敗,它會回傳 NULL,而原本的記憶體區塊仍然有效。因此應先用暫存指標接收結果,確認成功後再更新 arr。
解題方法
將所需容量換算成位元組數:
調整成功後,將新位置存回 arr,後續才能安全地寫入 arr[n]。若調整失敗,釋放原本的記憶體並回傳 NULL,避免記憶體洩漏。
int *tmp = (int*)realloc(arr, (n + 1) * sizeof(int));
if (tmp == NULL) {
free(arr);
return NULL;
}
arr = tmp;
第 12 題5 分
- Assume the programmer chose the best answer for statement A. Which memory-related issue can still
occur in the full program?
(A) The program has a use-after-free because free (p) is executed before printf
(B) The program will always double-free because process() frees arr and main() frees it again
(C) If memory allocation fails, main() may dereference a NULL pointer in printf("%d\n", *p);
(D) The statement arr[n] = -1; always causes a buffer overflow because arr has length n
登入後即可作答並保存紀錄。
本題延續上一題的程式碼,假設 Statement A 已經被正確填寫(即使用帶有錯誤處理的 realloc)。我們需要找出在完整的程式中,仍然可能發生的記憶體相關問題。
完整的程式碼(假設 Statement A 是選項 (A)):
int* process(int n) {
int *arr = (int*) malloc(n * sizeof(int));
if (arr == NULL) return NULL; // Case 1: Initial malloc fails
for (int i = 0; i < n; i++) {
arr[i] = 1 * 2;
}
// Statement A (Option A from Q11):
int *tmp = (int*)realloc(arr, (n + 1) * sizeof(int));
if (tmp == NULL) { // Case 2: realloc fails
free(arr);
return NULL;
}
arr = tmp;
arr[n] = -1; // This assignment is now safe because arr has size n+1
return arr;
}
int main() {
int *p = process(5);
// Missing statement B
printf("%d\n", *p); // This prints the first element of the array
free(p);
return 0;
}
現在分析選項:
(A) The program has a use-after-free because free (p) is executed before printf:
* free(p) 在 printf 之後執行。因此,這不是 use-after-free。
* 評估: 錯誤。
(B) The program will always double-free because process() frees arr and main() frees it again:
第 13 題5 分
- Suppose Missing statement B is completed as below, what value will be printed?
p = p + 1;
*p = *(p + 3);
(A) 0
(B) 2
(C) 8
(D) -1
登入後即可作答並保存紀錄。
本題考驗 C 語言指標運算和記憶體存取。我們需要根據 process 函數的行為以及 Statement B 的內容,推斷 printf 會印出什麼值。
首先,我們知道 process(5) 返回一個指向記憶體區塊的指標 p。這個記憶體區塊是動態分配的,並且(假設 Statement A 已正確填寫)至少能容納 6 個整數(索引 0 到 5)。
process(5) 的行為:
- 分配
5 * sizeof(int)的記憶體。 - (假設成功)分配
(5+1) * sizeof(int)的記憶體。 - 將
arr[0]到arr[4]設為1 * 2(即 2)。 - 將
arr[5]設為-1。 - 返回
arr的指標。
所以,p 指向的記憶體區塊(假設是 arr)的內容是:
p[0] = 2
p[1] = 2
p[2] = 2
p[3] = 2
p[4] = 2
p[5] = -1
現在看 Missing statement B:
p = p + 1;
*p = *(p + 3);
第 14 題5 分
Question Group 2 (20%, each 5%)
Consider the following diagram shows an Agentic Large Language Model (LLM) System, and answer
question 14 to 17.
[Diagram shows an Agentic LLM System with components: LLM, Tools, Memory, and a workflow: Plan/Reason/Evaluate -> Use Tools -> Execute Action -> Update Memory -> LLM]
- Which neural network architecture is most commonly used for text generation in modern LLMs?
(A) Generative Adversarial Network
(B) Long Short-Term Memory Recurrent Neural Network
(C) Variational Autoencoder
(D) Decoder-only Transformer
登入後即可作答並保存紀錄。
本題考驗現代大型語言模型 (LLMs) 中最常用的神經網路架構。
現代 LLMs,例如 GPT 系列、BERT 等,其核心架構是 Transformer。而 Transformer 模型中,最適合進行序列生成任務(如文本生成)的部分是其解碼器 (Decoder) 部分。
分析選項:
(A) Generative Adversarial Network (GAN): GAN 通常用於生成圖像,雖然理論上也可用於序列生成,但不是現代 LLMs 的主流架構。
(B) Long Short-Term Memory (LSTM) Recurrent Neural Network: LSTM 曾是處理序列資料的強大模型,在 Transformer 出現之前廣泛應用於自然語言處理。
第 15 題5 分
- A user asks an agentic LLM: "Find the current stock price of TSMC and calculate how much 100
shares would cost in USD and TWD." Assume the system has access to a stock API and a currency
conversion API. Which behavior correctly follows the agentic workflow?
(A) Call stock API → Call currency API → Calculate both values in parallel → Return results
(B) Identify two sub-tasks → Call stock API → Evaluate result → Plan currency conversion → Call
currency API → Calculate → Verify → Return results
(C) Call stock API and currency API simultaneously → Combine results → Return answer
(D) Retrieve stock price and exchange rate from memory → Calculate → Verify with tools → Return
resultss
登入後即可作答並保存紀錄。
本題考驗具備代理 (agentic) 功能的大型語言模型 (LLM) 的工作流程。代理 LLM 通常包含規劃、使用工具、執行和記憶等步驟。題幹描述了一個用戶請求,需要 LLM 透過外部工具(股票 API 和貨幣轉換 API)來完成。
我們分析圖示中的代理 LLM 工作流程:
- Plan / Reason / Evaluate (規劃/推理/評估): LLM 接收到用戶請求後,需要理解請求的意圖,並規劃如何達成目標。這可能包括分解任務、選擇合適的工具。
- Use Tools (使用工具): 根據規劃,LLM 會選擇並呼叫外部工具(如 API)。
- Execute Action (執行動作): 工具執行後返回結果。
- Update Memory (更新記憶體): 處理工具的結果,並將相關資訊存儲在記憶體中,以便後續使用或改進。
- LLM (回到 LLM): LLM 根據工具的結果和記憶體中的資訊,進一步推理,可能需要再次規劃或生成最終回應。
現在分析選項:
(A) Call stock API → Call currency API → Calculate both values in parallel → Return results
* 這個流程比較簡化,但「Call stock API」和「Call currency API」是使用工具的步驟。
* 「Calculate both values in parallel」可能暗示了某種程度的規劃和執行。
* 然而,它沒有明確體現「Plan/Reason/Evaluate」和「Update Memory」的步驟。
(B) **Identify two sub-tasks → Call stock API → Evaluate result → Plan currency conversion → Call currency API → Calculate → Verify → Return resul
第 16 題5 分
- Which of the following techniques is generally NOT intended to reduce hallucination in an agentic AI
system?
(A) Increasing sampling temperature
(B) Retrieval-Augmented Generation (RAG)
(C) Tool-based verification
(D) Self-reflection or consistency checking
登入後即可作答並保存紀錄。
本題考驗減少 AI 系統(特別是 LLM)「幻覺」(hallucination) 的技術。幻覺是指 AI 生成了不真實、不準確或毫無根據的資訊。
分析選項:
(A) Increasing sampling temperature:
* Sampling temperature 是控制 LLM 生成文本隨機性的一個參數。
* 較高的 temperature 會增加生成文本的隨機性,使其更多樣化、更有創意,但也更容易產生幻覺。
* 較低的 temperature 會使生成文本更確定、更集中於模型訓練數據中最常見的模式,從而有助於減少幻覺。
* 因此,提高 sampling temperature 不是用來減少幻覺的技術,反而可能加劇幻覺。
(B) Retrieval-Augmented Generation (RAG):
* RAG 是一種將外部知識庫(如文件、資料庫)檢索到的資訊與 LLM 的生成能力結合的技術。
第 17 題5 分
- Which of the following is NOT commonly encountered as an attack in an agentic LLM system?
(A) Prompt injection
(B) Model inversion
(C) Membership inference
(D) Least-privilege tool access control
登入後即可作答並保存紀錄。
本題考驗針對代理 (agentic) LLM 系統的常見攻擊類型。
分析選項:
(A) Prompt injection:
* 這是一種常見的攻擊,攻擊者通過精心構造的輸入提示 (prompt),繞過 LLM 的安全限制,使其執行非預期的操作,例如洩漏敏感資訊、生成有害內容,或執行惡意工具。
* 在代理 LLM 中,攻擊者可以利用工具調用機制來實現更複雜的攻擊。
* 這是一種常見的攻擊。
(B) Model inversion:
* 模型反演攻擊旨在從訓練好的模型中恢復訓練資料的某些資訊,甚至可能恢復部分訓練資料本身。
* 這類攻擊主要關注模型的訓練資料隱私,對於代理 LLM 的「行為」本身(即如何使用工具、如何規劃)的攻擊性較弱,但仍可能與 LLM 的模型隱私相關。
* 這是一種潛在的攻擊,但對於代理 LLM 的「系統」而言,相較於 prompt injection,其直接影響可能較小。
第 18 題5 分
Question Group 3 (15%, each 5%)
Consider the output of a student's ipconfig command below, and answer question 18 to 20.
IPv4 Address : 192.168.1.23
Subnet Mask : [hidden]
Default Gateway : 192.168.1.1
- Which operating system is most likely being used?
(A) FreeBSD
(B) Windows (PowerShell/Command Prompt)
(C) Ubuntu
(D) macOS
登入後即可作答並保存紀錄。
本題考驗根據網路組態命令的輸出,判斷作業系統的類型。題目提供了 ipconfig 命令的輸出。
ipconfig 是 Windows 作業系統中用於顯示網路組態資訊的命令。在 Linux/macOS 等系統中,類似的命令是 ifconfig 或 ip addr。
第 19 題5 分
- Assuming a typical home or campus LAN configuration, what is the most likely subnet mask?
(A) 255.0.0.0
(B) 255.255.0.0
(C) 255.255.255.0
(D) 255.255.255.255
登入後即可作答並保存紀錄。
本題考驗 IP 位址和子網路遮罩 (subnet mask) 的概念,尤其是在典型的家庭或校園區域網路 (LAN) 環境中。
提供的網路組態:
- IPv4 Address: 192.168.1.23
- Default Gateway: 192.168.1.1
IP 位址 192.168.1.23 屬於 A 類 IP 位址的私有 IP 位址範圍 (192.168.0.0 - 192.168.255.255)。
預設閘道 192.168.1.1 的網路位址部分與 IP 位址 192.168.1.23 的網路位址部分應該相同。
我們來分析選項:
- A. 255.0.0.0: 這是 A 類網路的預設子網路遮罩,用於
1.x.x.x這樣的位址。它會將第一個位元組作為網路位址,後三個位元組作為主機位址。如果使用這個遮罩,192.168.1.23的網路位址將是192.0.0.0,這與預設閘道192.168.1.1(網路位址應為192.0.0.0) 的網路位址部分不符。 - B. 255.255.0.0: 這是 B 類網路的預設子網路遮罩。如果使用這個遮罩,
192.168.1.23的網路位址將是192.168.0.0。
第 20 題5 分
- Which device is responsible for assigning the IP address shown above?
(A) Internet Service Provider (ISP)
(B) DNS Server
(C) DHCP Server
(D) Network Interface Card (NIC)
登入後即可作答並保存紀錄。
本題考驗 IP 位址分配的機制。題目中的 IP 位址 192.168.1.23 是私有 IP 位址,並且是通過 ipconfig 命令獲取的。
在區域網路 (LAN) 中,IP 位址通常是動態分配的,以簡化網路管理。這個動態分配的過程是由 DHCP (Dynamic Host Configuration Protocol) 伺服器來完成的。
分析選項:
(A) Internet Service Provider (ISP): ISP 分配的是公共 IP 位址給路由器(通常是 NAT 之前),而不是給 LAN 內的主機分配私有 IP 位址。