114 年 國立臺灣大學資訊管理學系碩士班《資訊科技概論》
第 1 題2 分
Which of the following best describes the purpose of recursion in programming?
(A) To optimize memory usage by eliminating loops
(B) To solve problems by breaking them down into smaller, similar subproblems
(C) To execute multiple tasks simultaneously using threads
(D) To perform operations on arrays more efficiently
(E) To handle errors during runtime automatically.
登入後即可作答並保存紀錄。
本題在考驗對遞迴(Recursion)概念的理解。遞迴是一種程式設計技巧,其中一個函式會呼叫自身來解決問題。
核心觀念:遞迴的核心在於「重複呼叫自身」以解決「可以分解成更小、相似問題」的情境。
解題思路:
(A) 遞迴通常會增加記憶體使用,因為每次函式呼叫都會在堆疊(stack)上建立新的框架,而不是像迴圈那樣節省記憶體。
(B) 這是遞迴的定義。
第 2 題2 分
In object-oriented programming, what is the primary purpose of polymorphism?
(A) To allow objects to inherit multiple classes
(B) To provide a single interface for different implementations
(C) To encapsulate data within a single class
(D) To reuse existing code in derived classes
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗物件導向程式設計(Object-Oriented Programming, OOP)中的多型(Polymorphism)概念。
核心觀念:多型允許以統一的方式處理不同類型的物件,只要它們共享一個共同的介面或基底類別。
解題思路:
(A) 允許物件繼承多個類別是「多重繼承」(Multiple Inheritance)的概念,並非多型的主要目的。許多語言(如 Java)不支援多重繼承,但仍有強大的多型機制。
(B) 這是多型的核心。多型使得我們可以編寫能夠處理不同物件的程式碼,而無需知道物件的具體類型。
第 3 題2 分
Which of the following data structures is most suitable for implementing a priority queue?
(A) Stack
(B) Queue
(C) Binary Heap
(D) Linked List
(E) Hash Table.
登入後即可作答並保存紀錄。
本題考驗資料結構與優先權佇列(Priority Queue)的實現。
核心觀念:優先權佇列是一種抽象資料型別,其中每個元素都有一個優先權。當從佇列中移除元素時,具有最高優先權的元素會被移除。
解題思路:
(A) 堆疊(Stack)是後進先出(LIFO)的結構,不適合實現優先權佇列。
(B) 標準佇列(Queue)是先進先出(FIFO)的結構,不適合實現優先權佇列,除非進行額外排序。
(C) 二元堆(Binary Heap)是實現優先權佇列最常見且效率最高的方式之一。
第 4 題2 分
Which of the following traversal techniques produces a sorted order for a binary search tree (BST)?
(A) Preorder traversal
(B) Postorder traversal
(C) Inorder traversal
(D) Level-order traversal
(E) Reverse level-order traversal.
登入後即可作答並保存紀錄。
本題考驗二元搜尋樹(Binary Search Tree, BST)的遍歷順序及其特性。
核心觀念:二元搜尋樹的定義是:對於任意節點,其左子樹的所有節點的值都小於該節點的值,其右子樹的所有節點的值都大於該節點的值。
解題思路:
(A) 前序遍歷(Preorder Traversal):根節點 -> 左子樹 -> 右子樹。例如,對 BST 進行前序遍歷,得到的序列不一定是排序的。
(B) 後序遍歷(Postorder Traversal):左子樹 -> 右子樹 -> 根節點。同樣,得到的序列不一定是排序的。
第 5 題2 分
Consider the following algorithm for sorting an array of N numbers. It starts from the 1st element of the array and compares it with the 2nd element. If the 1st element is greater than the 2nd, the two elements are swapped. Then, the 2nd element is compared with the 3rd element, and the two swapped if the 2nd element is greater. The process continues until the end of the array. The entire process is repeated for the first N-1 elements, N-2, and so on if the array is not yet sorted. What is the worst-case time complexity to sort an array of N numbers?
(A)
(B)
(C)
(D)
(E) none of the above.
登入後即可作答並保存紀錄。
核心觀念
題目描述的是泡沫排序法(Bubble Sort):從左到右比較相鄰元素,若順序相反就交換。每一輪會把尚未排序區段中的最大值推到最右側,因此後續每輪需處理的元素數逐漸減少。
時間複雜度依輸入規模 增長的最高階項表示;若執行步數與 成正比,則時間複雜度為 。
解題方法
最壞情況可用逆序陣列說明,例如由大到小排列。每一輪都必須比較相鄰元素,且需要大量交換,無法提早完成排序。
各輪比較次數依序為:
這是等差級數,總和為:
最高階項是 ,因此最壞情況的時間複雜度為 ,也就是選項所列的 。
選項分析
第 6 題2 分
Continue the above question. What is the best-case time complexity?
(A)
(B)
(C)
(D)
(E)
登入後即可作答並保存紀錄。
核心觀念
題幹中的「above question」未附上,因此缺少前一題的程式碼。以下依與本題選項相符的標準前提說明:上題包含兩層獨立迴圈,且每次迭代都將控制變數乘以 ,例如:
for (i = 1; i <= N; i = 2i)
for (j = 1; j <= N; j = 2j)
execute constant-time operation
此類迴圈的核心是對數成長:
當 時,迭代次數滿足:
解題方法
外層迴圈執行 次。
對外層的每一次迭代,內層迴圈同樣執行 次。因此總執行次數為:
若每次迴圈內的操作為常數時間 ,總時間複雜度就是:
由於題目所述迴圈沒有依據資料內容提前結束,best-case 與 worst-case 的迭代次數相同,因此 best-case time complexity 仍為:
第 7 題2 分
In file systems, what is the primary purpose of an inode?
(A) To store the actual content of a file
(B) To store metadata about a file, such as permissions and timestamps
(C) To allocate disk blocks to a file
(D) To index all files in a directory
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗檔案系統(File System)中 inode 的作用。
核心觀念:inode(index node)是 Unix-like 檔案系統中的一個重要結構,用於儲存檔案或目錄的元數據(metadata)。
解題思路:
(A) 檔案的實際內容(即數據)通常儲存在磁碟上的數據塊(data blocks)中,而不是 inode 中。Inode 僅指向這些數據塊。
(B) 這是 inode 的主要功能。
第 8 題2 分
Which of the following best describes the Banker's Algorithm in an operating system?
(A) It is a deadlock avoidance algorithm that checks resource allocation safety.
(B) It ensures mutual exclusion in critical section problems.
(C) It schedules processes in a round-robin manner.
(D) It optimizes disk scheduling to reduce seek time.
(E) It manages cache replacement in virtual memory systems.
登入後即可作答並保存紀錄。
本題考驗作業系統(Operating System)中銀行家演算法(Banker's Algorithm)的功能。
核心觀念:銀行家演算法是一種用於死鎖預防(deadlock prevention)或死鎖避免(deadlock avoidance)的資源分配演算法。
解題思路:
(A) 這是銀行家演算法的精確描述。它透過檢查系統的資源分配狀態是否處於「安全狀態」(safe state),來避免死鎖的發生。如果系統能找到一個進程執行序列,使得所有進程都能在有限的時間內完成其資源請求,那麼該狀態就是安全的。
第 9 題2 分
In a multilevel feedback queue scheduling algorithm, which of the following is true?
(A) Processes are assigned to a single queue for their entire lifetime.
(B) The algorithm ensures that all processes are executed in a round-robin manner.
(C) Processes can move between queues based on their behavior and priority.
(D) Only I/O-bound processes are prioritized over CPU-bound processes.
(E) The algorithm is non-preemptive by default.
登入後即可作答並保存紀錄。
本題考驗作業系統中的多層次回饋佇列(Multilevel Feedback Queue)排程演算法。
核心觀念:多層次回饋佇列是一種動態的排程演算法,它允許進程根據其行為(如 CPU 使用情況或 I/O 操作)在不同優先權的佇列之間移動。
解題思路:
(A) 這是多層次佇列(Multilevel Queue)的特點,但在多層次回饋佇列中,進程可以根據行為在佇列間移動。
(B) 雖然回饋佇列通常包含輪詢(round-robin)機制,但並非所有進程都以輪詢方式執行,且回饋機制是其關鍵。
(C) 這是多層次回饋佇列的核心特徵。
第 10 題2 分
What is the primary purpose of a semaphore in an operating system?
(A) To manage CPU scheduling among processes
(B) To ensure mutual exclusion in concurrent programming
(C) To optimize memory allocation in virtual memory
(D) To transfer data between user and kernel space
(E) To prioritize processes in a scheduling queue.
登入後即可作答並保存紀錄。
本題考驗作業系統中信號量(Semaphore)的主要用途。
核心觀念:信號量是一種用於控制多個進程或執行緒對共享資源訪問的同步機制。
解題思路:
(A) CPU 調度管理是排程器(scheduler)的職責。
(B) 這是信號量的最主要用途之一。信號量可以用來實現臨界區(critical section)的互斥訪問。
第 11 題2 分
In the context of virtual memory, what is the purpose of a page table?
(A) To map virtual addresses to physical addresses
(B) To store process control information
(C) To manage CPU scheduling among processes
(D) To optimize I/O device access
(E) To allocate space in secondary storage for processes.
登入後即可作答並保存紀錄。
本題考驗虛擬記憶體(Virtual Memory)中的頁表(Page Table)的作用。
核心觀念:虛擬記憶體允許程式使用比實際物理記憶體更大的地址空間,這需要一種機制來將程式使用的虛擬地址轉換為實際的物理地址。
解題思路:
(A) 這是頁表的核心功能。在虛擬記憶體系統中,程式看到的地址是虛擬地址。當 CPU 存取記憶體時,需要將虛擬地址轉換為對應的物理地址,以便在實際的 RAM 中進行存取。
第 12 題2 分
Which SQL clause is used to filter groups of data after applying an aggregate function?
(A) DISTINCT
(B) GROUP BY
(C) HAVING
(D) ORDER BY
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗 SQL(Structured Query Language)的語法和功能,特別是關於聚合函數和分組過濾。
核心觀念:SQL 用於管理和查詢關聯式資料庫。聚合函數(如 SUM, AVG, COUNT, MAX, MIN)對一系列值進行計算,而分組和過濾則用於精確控制哪些數據被處理和顯示。
解題思路:
(A) DISTINCT:用於移除查詢結果中的重複行。
(B) GROUP BY:用於將具有相同值的行分組,以便對每個組應用聚合函數。例如,GROUP BY department 會將所有來自同一部門的記錄分組。
(C) HAVING:用於在 GROUP BY 子句之後,根據聚合函數的結果過濾這些分組。
第 13 題2 分
In the context of database normalization, what is the purpose of 3NF (Third Normal Form)?
(A) To ensure that non-primary-keys are transitively dependent
(B) To ensure that all attributes are dependent only on the primary key
(C) To reduce the number of tables in a schema.
(D) To ensure that no non-primary-key attribute is transitively dependent on the primary key
(E) To ensure that foreign keys reference valid primary keys.
登入後即可作答並保存紀錄。
本題考驗資料庫正規化(Database Normalization)中的第三正規化形式(3NF)的目的。
核心觀念:正規化是設計關聯式資料庫的過程,旨在減少資料冗餘和提高資料完整性。3NF 是正規化的一個重要階段。
3NF 的定義是:一個關係模式 處於 3NF,若且唯若它處於 2NF,並且 中的任何非主屬性(non-prime attribute)都不能傳遞依賴(transitively dependent)於主鍵(primary key)。
傳遞依賴是指:如果存在屬性集 ,使得 且 ,其中 不是 的超鍵(superkey),且 不是 的一部分(即 且 不是 的超鍵),則稱 傳遞依賴於
第 14 題2 分
What is the primary purpose of the JOIN operation in SQL?
(A) To create a temporary table from existing tables
(B) To combine columns from two or more tables based on a related column
(C) To remove duplicate rows from a table
(D) To restrict the rows returned by a query
(E) To calculate aggregate values across multiple tables.
登入後即可作答並保存紀錄。
本題考驗 SQL 中 JOIN 操作的核心目的。
核心觀念:在關聯式資料庫中,資料通常被分解到多個表中以減少冗餘(正規化)。JOIN 操作用於將這些分散的資料重新組合起來,以便進行查詢。
解題思路:
(A) 建立臨時表通常使用 CREATE TEMPORARY TABLE 或 SELECT INTO 等語句,JOIN 操作本身不直接創建臨時表,而是用於從現有表中查詢數據。
(B) 這是 JOIN 操作的定義。
第 15 題2 分
Which of the following is true about NoSQL databases compared to relational databases?
(A) NoSQL databases do not support indexing.
(B) NoSQL databases use a fixed schema for data storage.
(C) NoSQL databases are better suited for structured data.
(D) NoSQL databases are typically more scalable for distributed systems.
(E) NoSQL databases do not support transactions.
登入後即可作答並保存紀錄。
本題考驗 NoSQL 資料庫與關聯式資料庫(Relational Databases)的比較。
核心觀念:NoSQL(Not Only SQL)是一類非關聯式的資料庫,它們在設計理念、資料模型和擴展性等方面與傳統的關聯式資料庫有顯著差異。
解題思路:
(A) 這是錯誤的。大多數 NoSQL 資料庫都支援索引,例如 MongoDB 的 BSON 索引、Cassandra 的索引等,以便提高查詢效率。
(B) 這是錯誤的。關聯式資料庫通常使用固定的、預定義的結構化模式(schema)。而許多 NoSQL 資料庫(如文檔資料庫、鍵值儲存)是「無模式」(schema-less)或「動態模式」(dynamic schema),允許在儲存數據時不需要預先定義所有欄位,或者模式可以隨時改變。
(C) 這是錯誤的。關聯式資料庫以其嚴謹的結構化模式,非常適合儲存結構化數據。
第 16 題2 分
In an ER (Entity-Relationship) diagram, what does a diamond-shaped symbol represent?
(A) An attribute of an entity
(B) A primary key
(C) A weak entity
(D) A multivalued attribute
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗實體關聯圖(Entity-Relationship Diagram, ERD)中的符號含義。
核心觀念:ERD 是用來視覺化資料庫結構的工具,其中不同的符號代表不同的資料庫概念。
解題思路:
(A) 實體的屬性(attribute)通常用橢圓形(oval)表示。
(B) 主鍵(primary key)通常在屬性名稱下劃線,或者在某些表示法中用特殊標記表示。
第 17 題2 分
What is the primary purpose of a database transaction log?
(A) To store the results of executed queries for future reference.
(B) To keep a record of all changes made to the database for recovery purposes.
(C) To optimize the execution of complex queries.
(D) To maintain a backup copy of the entire database.
(E) To store metadata about tables and indexes.
登入後即可作答並保存紀錄。
本題考驗資料庫交易日誌(Database Transaction Log)的主要目的。
核心觀念:交易日誌(也稱為寫入預寫日誌,Write-Ahead Logging, WAL)是資料庫系統中用於確保資料持久性和可用性的關鍵機制。
解題思路:
(A) 查詢結果通常不儲存在交易日誌中,除非是為了特定目的(如緩存),但這不是日誌的主要目的。
(B) 這是交易日誌的核心功能。在資料庫系統中,任何對資料的修改(插入、更新、刪除)都會先被記錄在交易日誌中,然後才應用到實際的數據文件中。
第 18 題2 分
What is a composite key in a relational database?
(A) A key that consists of multiple columns to uniquely identify a row.
(B) A key that acts as a foreign key in multiple tables.
(C) A primary key that has been indexed for performance optimization.
(D) A key that references another table's unique identifier.
(E) A virtual key created by combining data from different tables.
登入後即可作答並保存紀錄。
本題考驗關聯式資料庫中的複合鍵(Composite Key)的定義。
核心觀念:在關聯式資料庫中,主鍵(Primary Key)用於唯一標識表格中的每一行。主鍵可以由一個或多個屬性組成。
解題思路:
(A) 這是複合鍵的精確定義。一個複合鍵是由兩個或多個欄位(屬性)組合而成,它們共同作用以唯一標識表格中的每一條記錄。
(B) 一個鍵可以作為外鍵(Foreign Key)引用其他表的主鍵,但這與複合鍵的定義不同。
第 19 題2 分
What is the main purpose of a subnet mask in TCP/IP?
(A) To identify the default gateway
(B) To define the host and network portions of an IP address
(C) To encrypt data packets
(D) To limit the size of a packet
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗 TCP/IP 協定中子網路遮罩(Subnet Mask)的主要作用。
核心觀念:IP 位址用於在網路上唯一識別設備。子網路遮罩用於確定 IP 位址的哪一部分代表網路,哪一部分代表主機。
解題思路:
(A) 預設閘道(default gateway)是由路由器配置的,並不是由子網路遮罩決定的。
(B) 這是子網路遮罩的核心功能。一個 IP 位址(如 IPv4)可以被看作是網路位址和主機位址的組合。
第 20 題2 分
What is the purpose of the "window size" field in the TCP header?
(A) to specify the number of bytes that can be sent before an acknowledgment is received
(B) To determine the length of the TCP header
(C) To indicate the size of the sliding window buffer
(D) To synchronize the sequence numbers of the sender and receiver
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗 TCP(Transmission Control Protocol)標頭(header)中的「視窗大小」(window size)欄位的作用。
核心觀念:TCP 是一種可靠的、面向連接的傳輸層協定。為了提高傳輸效率並處理網路擁塞,TCP 使用了「滑動視窗」(Sliding Window)機制。
解題思路:
(A) 這是視窗大小欄位的精確含義。視窗大小表示接收端緩衝區中可用空間的大小,也就是發送端在收到接收端的確認(ACK)之前,可以連續發送的最大資料位元組數。這是一種流量控制(flow control)機制。
第 21 題2 分
Which routing algorithm is used by OSPF (Open Shortest Path First)?
(A) Distance Vector
(B) Link State
(C) Path Vector
(D) Flooding
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗路由協定 OSPF(Open Shortest Path First)所使用的路由演算法類型。
核心觀念:路由器使用路由協定來交換網路資訊,並建立路由表。不同的路由協定採用不同的演算法來計算最佳路徑。
解題思路:
(A) 距離向量(Distance Vector)演算法是 RIP(Routing Information Protocol)等協定採用的。它基於「毒性逆轉」(poison reverse)和「水平分割」(split horizon)等概念,透過交換整個路由表來更新鄰居的路由資訊。
(B) 連結狀態(Link State)演算法是 OSPF 和 IS-IS 等協定採用的。它要求每個路由器將其所有直接連接的網路連結的狀態(如到達鄰居的成本)廣播給網路中的所有其他路由器。
第 22 題2 分
Which of the following statements about NAT (Network Address Translation) is INCORRECT?
(A) NAT can hide internal IP addresses from external networks.
(B) NAT helps conserve IPv4 address space.
(C) NAT can interfere with end-to-end connectivity for some applications.
(D) NAT operates at the Network layer of the OSI model.
(E) all of the above are correct (choose this one only if none of the above can be chosen).
登入後即可作答並保存紀錄。
本題考驗網路位址轉換(Network Address Translation, NAT)的相關敘述,要求找出錯誤的選項。
核心觀念:NAT 是一種將私有 IP 位址轉換為公共 IP 位址(或反之)的技術,主要用於解決 IPv4 位址不足的問題,並提供一定的安全隔離。
解題思路:
(A) 這是 NAT 的一個主要優點。通過將內部私有 IP 位址映射到一個或多個公共 IP 位址,NAT 可以隱藏內部網路的結構和主機的真實 IP 位址,從而提供一層安全保護。
(B) 這是 NAT 的最主要目的之一。
第 23 題2 分
What is the primary purpose of the Domain Name System (DNS)?
(A) To assign IP addresses to devices on a network
(B) To translate domain names into IP addresses
(C) To encrypt communication between devices
(D) To manage routing tables in a network
(E) To speed up routing between Internet hosts.
登入後即可作答並保存紀錄。
本題考驗網域名稱系統(Domain Name System, DNS)的主要目的。
核心觀念:DNS 是一個分佈式的命名系統,用於將人類可讀的網域名稱(如 www.google.com)解析為機器可讀的 IP 位址(如 172.217.160.142)。
解題思路:
(A) 為網路上的設備分配 IP 位址通常由 DHCP(Dynamic Host Configuration Protocol)伺服器負責。
(B) 這是 DNS 的核心功能。DNS 伺服器維護著一個龐大的資料庫,將網域名稱與對應的 IP 位址進行映射。
第 24 題2 分
Which of the following is INCORRECT about Software-Defined Networking (SDN)?
(A) Data and control planes are tightly integrated.
(B) SDN separates the control plane from the data plane.
(C) SDN enables programmable networks using APIs.
(D) SDN uses abstraction to enable dynamic and programmatically efficient network configuration.
(E) all of the above are correct (choose this one only if none of the above can be chosen).
登入後即可作答並保存紀錄。
本題考驗軟體定義網路(Software-Defined Networking, SDN)的概念,要求找出錯誤的敘述。
核心觀念:SDN 是一種網路架構,它將網路的控制功能與資料轉發功能分離,使得網路的行為可以透過軟體來程式化和管理。
解題思路:
(A) 這是傳統網路架構的特點,其中路由器和交換機等網路設備同時負責控制(決定封包如何轉發)和數據轉發(實際移動封包)。SDN 的核心就是打破這種緊密整合。
(B) 這是 SDN 的基本原則。SDN 將網路的控制平面(負責決策,如路由、流量管理)與數據平面(負責實際的封包轉發)分離。
第 二、問答題 1 題40 分
The following shows a pointer-based implementation of ADT Queue, which stores non-negative integers in a circular linked list with one pointer - backptr pointing to the last item in the list.
class Queue
{
public:
// return -1 if there is no integer in the queue;
// otherwise, return the front integer in the queue
int dequeue();
// return the number of integers in the queue
int length();
// reverse the order of the integers in the queue
void reverse();
private:
struct QueueNode
{
int
item;
QueueNode
*next;
} // end QueueNode
QueueNode *backPtr;
};
(a) (5 points) Write the Queue:: length () function that returns the number of integers in the queue.
(b) (10 points) Write the Queue:: dequeue() function that outputs the front integer in the queue. Note:
The function returns -1 if there is no integer in the queue.
(c) (25 points) Write the Queue:: reverse() function that reverses the order of the integers in the
queue. Note: No extra memory allocation for queue nodes!!! Only pointer manipulation is allowed
when reversing the integers.
登入後即可作答並保存紀錄。
核心觀念
本題使用 單指標循環單向鏈結串列 來實作 ADT Queue。
backPtr指向 最後一個節點,其next成員指向 第一個節點(front),形成環形。- 空佇列的表示:
backPtr == nullptr。 - 佇列的基本操作(長度、出列、反轉)均只能透過 指標操作 完成,且 不可額外配置節點(reverse 要求 O(1) 追加記憶體)。
(a) Queue::length()
解題方法
遍歷環形鏈結串列一次即可計算節點個數。
- 若
backPtr == nullptr→ 佇列為空,回傳 0。 - 否則從
front = backPtr->next開始,以cur迭代,直到cur再次等於backPtr為止。每走一步cnt++。
關鍵程式
int Queue::length()
{
if (backPtr == nullptr) // 空佇列
return 0;
int cnt = 0;
QueueNode *cur = backPtr->next; // front 節點
do {
++cnt;
cur = cur->next;
} while (cur != backPtr->next); // 迴圈結束於再次回到 front
return cnt;
}
時間與空間複雜度
- 時間:( 為佇列長度)
- 空間:(僅使用常數個指標)
(b) Queue::dequeue()
解題方法
- 判斷空佇列:
backPtr == nullptr→ 回傳 -1。 - 取得前端節點
front = backPtr->next,保存其item作為回傳值。 - 若佇列僅有 一個節點(
front == backPtr),刪除後將backPtr設為nullptr。 - 否則將
backPtr->next指向front->next,即跳過前端節點。最後delete front。
關鍵程式
int Queue::dequeue()
{
if (backPtr == nullptr) // 空佇列
return -1;
QueueNode *front = backPtr->next; // 前端節點
int value = front->item; // 取得資料
if (front == backPtr) { // 只剩一個節點
delete front;
backPtr = nullptr;
} else {
backPtr->next = front->next; // 前端節點被移除
delete front;
}
return value;
}