108 年 國立臺灣大學資訊管理學系碩士班《資訊科技概論》
第 1 題2 分
Which of the following is not an image file format?
(A) JPEG
(B) MPEG
(C) GIF
(D) BMP
(E) all of the above are image file formats.
登入後即可作答並保存紀錄。
本題考驗對常見影像檔案格式的認知。
影像檔案格式主要用於儲存靜態圖片,例如 JPEG、GIF、BMP 等。
第 2 題2 分
Which of the following refers to a small piece of data sent from a website and stored on the user's computer by the user's web browser while the user is browsing so as to remember stateful information?
(A) proxy
(B) cookie
(C) etag
(D) http hash
(E) cache
登入後即可作答並保存紀錄。
本題考查網頁技術中用於維護狀態資訊(Stateful Information)的機制與相關網路術語。
一、核心概念與題幹解析:
HTTP 協定本身是一種無狀態(Stateless)通訊協定,這意味著伺服器在預設情況下不會在不同請求之間保存特定客戶端的關聯狀態。為了解決使用者登入認證、個人化偏好設定、購物車追蹤等跨請求的狀態維持需求,網頁技術發展出了 Cookie 機制。
題幹敘述:「指網站發送並由使用者的網頁瀏覽器儲存在使用者電腦上的一小段資料,以便在使用者瀏覽時記住具狀態性的資訊」,此完全符合 Cookie 的正式定義。
二、各選項逐一檢驗:
- (A) proxy(代理伺服器):位於客戶端與目標伺服器之間的中介網路實體,主要負責請求轉發、內容快取、存取控制或隱藏真實 IP 位址,並非儲存於瀏覽器內的狀態資料片段。
- (B) cookie:正確。由伺服器透過 HTTP 回應標頭(
Set-Cookie)發送至瀏覽器,瀏覽器將其儲存在本機端,並在後續向同一網域發出請求時透過Cookie標頭回傳給伺服器,專門用於識別使用者身分與維持對話狀態(Session Management)。
第 3 題2 分
How many distinct Internet addresses can IPv6 facilitate?
(A)
(B)
(C)
(D)
(E)
登入後即可作答並保存紀錄。
本題考驗對 IPv6 位址空間的知識。
IPv6 (Internet Protocol version 6) 是下一代網際網路協定,其位址長度為 128 位元。
第 4 題2 分
Which of the following (suite of) communication protocols are the foundation protocols used to interconnect network devices on the Internet?
(A) TCP/IP
(B) UDP/TCP
(C) HTTP
(D) HTTP/HTTPS
(E) DNS
登入後即可作答並保存紀錄。
本題考驗對網際網路基礎通訊協定的了解。
TCP/IP (Transmission Control Protocol/Internet Protocol) 是一個協定套件,它定義了網際網路資料傳輸的規則和架構。IP (網際網路協定) 負責位址分配和封包路由,而 TCP (傳輸控制協定) 則提供可靠的、面向連接的資料傳輸服務。這個協定套件是現代網際網路運作的基石。
第 5 題2 分
Which of the following is typically not a task of an operating system?
(A) CPU scheduling
(B) storage management
(C) memory allocation
(D) I/O management
(E) all of the above are common tasks of an operating system.
登入後即可作答並保存紀錄。
本題考驗對作業系統核心功能的認知。
作業系統 (Operating System, OS) 的主要職責包括管理系統資源,並為使用者和應用程式提供一個操作介面。
(A) CPU Scheduling (CPU 排程):作業系統負責分配 CPU 時間給不同的行程,使其能夠有效率地運行。
(B) Storage Management (儲存管理):作業系統負責管理硬碟、SSD 等儲存裝置的檔案系統、空間分配與存取。
第 6 題2 分
Which of the following is wrong?
(A) Linux is open source
(B) Linux is Unix-like
(C) Android is based on Linux
(D) Android is open source
(E) all of the above are correct (choose this one only if none of the above can be chosen).
登入後即可作答並保存紀錄。
本題考驗對 Linux 和 Android 相關知識的判斷。
(A) Linux 是開源軟體 (Open Source),使用者可以自由取得、修改和散佈原始碼。此敘述正確。
(B) Linux 是一個類 Unix (Unix-like) 的作業系統,其設計理念和許多指令與 Unix 系統相似。此敘述正確。
(C) Android 作業系統的核心是基於 Linux 核心。此敘述正確。
(D) Android 作業系統本身也是開源的 (基於 Apache 授權),但其包含的某些應用程式或服務可能不是開源的。
第 7 題2 分
Which of the following technologies is best used for tracking objects?
(A) smart card
(B) beacon
(C) RFID
(D) NFC
(E) IoT
登入後即可作答並保存紀錄。
本題考驗對物體追蹤技術的理解。
物體追蹤 (tracking objects) 通常涉及識別和定位特定物品或生物。
(A) Smart card (智慧卡):通常用於身分驗證或支付,本身不具備主動追蹤能力。
(B) Beacon (信標):是小型無線發射器,可以廣播識別訊號,常被用於室內定位和追蹤。
(C) RFID (Radio-Frequency Identification, 無線射頻辨識):透過無線電波辨識和追蹤附有 RFID 標籤的物體。它廣泛用於物品追蹤、存貨管理等。
(D) NFC (Near Field Communication, 近場通訊):是一種短距離無線通訊技術,用於設備間的互動,如支付或配對,但其範圍非常小,不適合遠距離追蹤。
第 8 題2 分
Which of the following technologies is seldom used in autonomous cars to perceive their surroundings?
(A) Lidar
(B) radar
(C) computer vision
(D) GPS
(E) all of the above are commonly used technologies.
登入後即可作答並保存紀錄。
核心觀念
本題考查自駕車的感知技術與定位技術之區別:
- 感知(Perception):偵測車輛周遭的物體、距離、速度、道路標線、交通號誌與行人等。
- 定位(Localization):判斷車輛目前所在的位置,常結合 GPS、慣性測量單元與高精度地圖。
- 導航(Navigation):根據目前位置與目的地規劃行駛路徑。
題目問的是「用來感知周遭環境」的技術,因此應選擇主要負責定位,而非直接偵測周遭物體的技術。
解題方法
逐一判斷各技術是否能直接取得周遭環境資訊:
- Lidar 可取得周遭物體的距離與空間形狀。
- Radar 可偵測物體距離、方位與相對速度。
- Computer vision 可透過攝影機辨識車道、號誌、行人與車輛。
- GPS 主要提供車輛的地理位置座標,並不直接感知周遭障礙物。
因此,GPS 雖然常整合於自駕車系統中,但它主要支援定位與導航,不是周遭環境感知的主要工具。
選項分析
(A) Lidar
Lidar(Light Detection and Ranging)利用雷射脈衝測量物體距離,依據光脈衝發射與反射返回的時間估算距離:
其中 為物體距離、 為光速、 為雷射往返時間,除以 是因為光線經過「去程」與「回程」。
Lidar 能建立周遭環境的三維點雲,用於辨識車輛、行人、路緣與障礙物,屬於常見的環境感知技術。本選項錯誤。
(B) Radar
Radar(Radio Detection and Ranging)利用無線電波偵測物體。除了估計距離與方向,還能利用都卜勒效應測量物體相對速度。
Radar 具有穿透雨、霧與灰塵的能力,常用於偵測前方車輛、盲點與側後方交通狀況,屬於常見的自駕車感知技術。本選項錯誤。
(C) Computer vision
Computer vision 通常使用攝影機影像分析周遭環境,可辨識:
- 車道線與道路邊界
- 交通號誌與標誌
- 行人、自行車與其他車輛
- 可行駛區域與障礙物
影像感知能提供豐富的色彩與語意資訊,是自駕車常用的環境感知技術。本選項錯誤。
(D) GPS
第 9 題2 分
Which of the following is an EU regulation on data protection and privacy for all individuals within the EU that replaces the 1995 EU Data Protection Directive and goes into force in May 2018?
(A) International Safe Harbor Privacy Principles
(B) Digital Millennium Copyright Act (DMCA)
(C) Digital Transition Content Security Act
(D) General Data Protection Regulation
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗對歐盟數據保護法規的認知。
歐盟於 2018 年 5 月 25 日生效的《通用資料保護條例》(General Data Protection Regulation, GDPR) 是針對所有歐盟公民的個人資料保護和隱私的一項重要法規,它取代了 1995 年的《歐盟資料保護指令》。
(A) International Safe Harbor Privacy Principles:這是美國與歐盟之間關於個人資料傳輸的協議,已於 2015 年被歐洲法院裁定無效。
第 10 題2 分
Which of the following is not considered as a specific attribute that defines big data?
(A) volume
(B) velocity
(C) variety
(D) veracity
(E) all of the above are specific attributes that define big data.
登入後即可作答並保存紀錄。
本題考驗對大數據 (Big Data) 特徵的理解。
大數據通常以「V」開頭的幾個屬性來定義,最經典的是 3V:
- Volume (資料量):指資料的規模巨大。
- Velocity (資料速度):指資料產生和處理的速度非常快。
- Variety (資料多樣性):指資料的類型多樣,包括結構化、半結構化和非結構化資料。
第 11 題2 分
Which of the following is not an application of big data?
(A) Decision making
(B) Forecast and Prediction
(C) Vulnerability Assessment
(D) Government Governance
(E) all of the above can be applications of big data.
登入後即可作答並保存紀錄。
本題考驗對大數據應用領域的認知。
大數據分析能夠從海量、多樣、高速的資料中提取有價值的洞見,應用範圍極為廣泛。
(A) Decision making (決策制定):透過大數據分析,企業和組織可以做出更明智、基於數據的決策。
(B) Forecast and Prediction (預測與預報):大數據模型常用於預測市場趨勢、天氣、疾病傳播等。
第 12 題2 分
The use of CAPTCHA (which requires user to type the letters of a distorted image, sometimes with the addition of an obscured sequence of letters or digits that appears on the screen) is an example of ____ that is meant to determine whether or not the user is human.
(A) Turing Test
(B) Alan Test
(C) Interactive Test
(D) AI Test
(E) Awareness Test
登入後即可作答並保存紀錄。
本題考驗對 CAPTCHA 技術及其背後概念的理解。
CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) 的全稱就已經說明了它的目的:一個自動化的公開圖靈測試,用來區分電腦和人類。
圖靈測試 (Turing Test) 是由艾倫·圖靈提出的,旨在測試機器是否能展現出與人類無法區分的智能行為。CAPTCHA 是一種反向的圖靈測試,它利用人類的視覺和認知能力(如辨識扭曲的文字)來驗證使用者是否為人類,從而阻止自動化程式(機器人)的惡意行為。
第 13 題2 分
Which of the following protocols, as part of X.500, is designed for enabling anyone to locate organizations, individuals, and other resources such as files and devices in a network, whether on the public Internet or on a corporate intranet?
(A) Free Directory Access Protocol (FDAP)
(B) Internet Directory Access Protocol (IDAP)
(C) Lightweight Directory Access Protocol (LDAP)
(D) Root Directory Access Protocol (RDAP)
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗對目錄服務協定的了解,特別是與 X.500 標準相關的協定。
X.500 是一系列國際標準,定義了目錄服務的結構和協定。LDAP (Lightweight Directory Access Protocol, 輕量級目錄存取協定) 是 X.500 的一個簡化版本,專門設計用於在網路上查詢和修改目錄服務中的資訊,例如使用者、
第 14 題2 分
Which of the following protocols provides a secure channel over an unsecured network in a client-server architecture, and was designed as a replacement for Telnet and for unsecured remote shell protocols such as the Berkeley rlogin and rsh?
(A) Secure Shell (SSH)
(B) Transport Layer Security (TLS)
(C) Secure Sockets Layer (SSL)
(D) Session Initiation Protocol (SIP)
(E) none of the above.
登入後即可作答並保存紀錄。
本題考查常見網路安全通訊協定的功能與設計歷史背景,特別是針對遠端終端連線與指令外殼(Remote Shell)協定的安全替代方案。
一、各選項逐一檢驗:
- (A) Secure Shell (SSH):正確。SSH 是一種在不安全網路上為主從式架構(Client-Server)提供安全加密通道的網路協定。在早期網際網路中,遠端管理伺服器普遍採用 Telnet、Berkeley rlogin、rsh 及 rcp 等協定,但這些舊式協定均以明文(Plaintext)形式傳輸帳號密碼與終端輸入,極易遭受網路監聽(Sniffing)與中間人攻擊。SSH 特別被設計用來完全取代 Telnet、rlogin 與 rsh,其透過非對稱密碼學驗證主機與身分,並以對稱加密保護連線資料流,具備完整性校驗與防禦竊聽及竄改之能力。
- (B) Transport Layer Security (TLS):TLS 是傳輸層安全協定(為 SSL 的後繼標準),主要為應用層協定(如 HTTPS、FTPS、SMTPS 等)提供端對端加密與完整性保護,並非直接針對 Telnet 或 rlogin/rsh 遠端外殼登入所設計的專用替代協定。
第 15 題2 分
Roughly speaking, the "deep" in "deep learning" neural networks refers to ____.
(A) the amount of data being trained
(B) the number of tags in input data
(C) the fan-in of a node
(D) the fan-out of a node
(E) none of the above.
登入後即可作答並保存紀錄。
本題考驗對深度學習 (Deep Learning) 名稱由來的理解。
「深度學習」之所以稱為「深度」,是因為其神經網路模型具有多層結構 (multiple layers)。這些層級結構使得模型能夠學習到資料中不同層次的抽象特徵,從而處理複雜的模式。
- (A) 資料量 (amount of data) 是影響模型訓練效果的因素,但不是「深度」的定義。
- (B) 標籤數 (number of tags) 通常指訓練資料的標註,與網路的深度無關。
第 16 題2 分
Which of the following is wrong about deep learning in AI?
(A) deep learning requires training data to teach the model how to derive output from input
(B) why an output is derived from the input may not be explained from the model
(C) for decision making, a biased input may yield a bias output
(D) training data usually have human marked information to teach the model what the input are
(E) all of the above are correct (choose this one only if none of the above can be chosen).
登入後即可作答並保存紀錄。
本題考查人工智慧(AI)中深度學習(Deep Learning)的核心特徵、訓練機制、黑盒子特性與潛在偏誤,要求選出敘述錯誤的選項。
一、深度學習之概念架構
深度學習是機器學習(Machine Learning)的一個重要分支,其特點是採用多層人工神經網路(Deep Neural Networks, DNN)自動從高維原始資料中學習多層次的特徵表示。深度學習涵蓋監督式學習、非監督式學習、自我監督學習與增強學習等多元典範。
二、各選項逐一分析:
- (A) deep learning requires training data to teach the model how to derive output from input:敘述正確。在常規深度學習任務中,模型必須透過大量的訓練資料,藉由損失函數(Loss Function)計算誤差並透過反向傳播演算法(Backpropagation)更新網路權重,從而學習由輸入特徵映射至目標輸出的複雜非線性函數。
- (B) why an output is derived from the input may not be explained from the model:敘述正確。深度神經網路通常包含數百萬乃至數千億個參數與多層非線性轉換,其內部表徵極其高度分散且抽象,導致模型的推論機制呈現「黑盒子(Black-Box)」特性,可解釋性(Explainability / XAI)較差,難以向人類精確闡明特定輸入產生特定輸出的因果邏輯。
- (C) for decision making, a biased input may yield a bias output:敘述正確。機器學習領域遵循「垃圾進,垃圾出(Garbage in, garbage out)」之原則。
第 17 題2 分
Which of the following is wrong about information security?
(A) Spyware is a type of malware designed to steal user data and sensitive information.
(B) A Trojan horse is a type of malware that is often disguised as legitimate software so as to mislead users of its true intent.
(C) A virus usually refers to a type of malicious programs that are able to actively replicate themselves and spread to other computers.
(D) A botnet refers to a network of hijacked zombie computers that are remotely controlled by a hacker.
(E) all of the above are correct (choose this one only if none of the above can be chosen).
登入後即可作答並保存紀錄。
本題考驗對資訊安全中常見惡意軟體和網路威脅的定義。
(A) Spyware (間諜軟體):確實是用來竊取使用者個人資訊、瀏覽習慣等敏感資料的惡意軟體。此敘述正確。
(B) Trojan horse (木馬程式):其特點是偽裝成合法軟體,誘騙使用者執行,從而達成其隱藏的惡意目的,如竊取資料、建立後門等。此敘述正確。
(C) Virus (電腦病毒):病毒的關鍵特徵是能夠自我複製並感染其他檔案或程式,進而散播到其他電腦。此敘述正確。
第 18 題2 分
In information security, which of the following terms more commonly refers to psychological manipulation of people into performing actions or divulging confidential information?
(A) Phishing
(B) Honeypot
(C) Spoofing
(D) Social Engineering
(E) Psychology Engineering.
登入後即可作答並保存紀錄。
本題考驗對資訊安全中「社會工程學」概念的理解。
社會工程學 (Social Engineering) 是指利用人性的弱點,透過心理操縱、欺騙、誘騙等手段,使人們自願或不自願地執行某些動作(如點擊惡意連結、洩漏密碼、提供敏感資訊)或洩漏機密資訊。
(A) Phishing (網路釣魚):是一種常見的社會工程學攻擊手法,透過偽裝成合法機構,誘騙使用者提供帳號密碼等敏感資訊。
(B) Honeypot (蜜罐):是一種誘餌系統,用於吸引攻擊者,從而偵測、分析攻擊手法。
第 19 題2 分
Which of the following helps protect computers by monitoring and controlling incoming and outgoing network traffic based on predetermined security rules?
(A) vulnerability scanner
(B) authentication scanner
(C) anti-virus software
(D) firewall
(E) eavesdropping software.
登入後即可作答並保存紀錄。
本題考驗對網路安全設備/軟體的了解。
防火牆 (Firewall) 的主要功能是在網路邊界設定安全策略,監控和控制進出網路的資料流量,只允許符合預設規則的流量通過,從而保護內部網路免受未經授權的存取或惡意攻擊。
(A) Vulnerability scanner (漏洞掃描器):用於掃描系統或網路,找出存在的安全漏洞。
(B) Authentication scanner (認證掃描器):通常用於測試系統的認證機制是否安全。
第 20 題2 分
Which of the following applications/protocols is typically not based on client-server architecture?
(A) network printing
(B) remote procedure call
(C) emails
(D) HTTP
(E) all of the above are based on client-server architecture.
登入後即可作答並保存紀錄。
本題考驗對不同應用程式/協定架構的判斷,找出非 Client-Server 架構的例子。
Client-Server 架構是指由一個或多個伺服器 (Server) 提供服務,而由多個客戶端 (Client) 向伺服器請求服務的架構模式。
(A) Network printing (網路列印):通常是 Client (使用者電腦) 發送列印請求給 Server (列印伺服器或印表機本身),伺服器負責處理列印任務。這是 Client-Server 架構。
(B) Remote Procedure Call (RPC, 遠端程序呼叫):RPC 允許一個程式在另一個地址空間(通常在另一台機器上)執行一個程序,而程序設計者對 RPC 的細節一無所知。這通常涉及 Client 發起 RPC 請求給 Server,Server 執行程序後回傳結果。這是 Client-Server 架構。
(C) Emails (電子郵件):電子郵件系統通常由郵件伺服器 (Mail Server) 和郵件客戶端 (Mail Client) 組成。用戶端透過郵件客戶端(如 Outlook, Gmail 網頁版)發送和接收郵件,郵件伺服器負責儲存和轉發郵件。
第 1 題15 分
HEAP is a complete binary tree that provides an efficient implementation of priority queues. Suppose we use a heap to manage a list of positive integers that large values mean high priority. The following C++ code fragment shows the class definition of the heap.
class HEAP
{
public:
int delete();
// return and delete the integer in the root of the heap
// return -1 if there is nothing to delete
bool insert(int newValue);
// insert newValue into the heap
// return false if the insertion is not successful
private:
int itemCount;
// number of heap items
int items [100]; // array of heap items
};
(a) Write the member function delete() that removes the integer in the root of the heap.
(b) Write the member function insert() that inserts a new integer into the heap.
登入後即可作答並保存紀錄。
本題考驗對二元堆積 (Binary Heap) 資料結構的實作能力,特別是最大堆積 (Max Heap) 的 delete 和 insert 操作。堆積是一種完全二元樹,常用於實作優先佇列。在此題目中,大值代表高優先權,故為最大堆積。
核心觀念:
最大堆積的性質:
- 堆積是一個完全二元樹。
- 任何節點的值都大於或等於其子節點的值(最大堆積性質)。
演算法步驟:
1. delete() 函數 (移除根節點,即最大值)
- 處理空堆積: 若
itemCount為 0,表示堆積為空,無法刪除,應返回 -1。 - 儲存根節點值: 根節點 (索引 0) 的值是我們要返回的最大值。
- 替換根節點: 將堆積的最後一個元素(即
items[itemCount - 1])移動到根節點的位置 (items[0])。 - 減少計數:
itemCount減 1。 - 堆積化 (Heapify Down / Sink): 新的根節點可能破壞了最大堆積的性質。需要從根節點開始,向下調整堆積,使其恢復堆積性質。這個過程稱為「堆積化下沉」(sink)。
- 從根節點 (索引
current = 0) 開始。 - 比較
current節點與其左右子節點(左子節索引2*current + 1,右子節索引2*current + 2)。 - 找出三個節點中值最大的節點(
current、左子節、右子節)。 - 如果最大的節點不是
current節點,則交換current節點與最大子節點的值。 - 更新
current為被交換的子節點索引,重複此過程,直到current節點大於其子節點,或current節點沒有子節點(即達到葉節點)。
- 從根節點 (索引
int HEAP::delete() {
if (itemCount == 0) {
return -1; // Heap is empty
}
int maxValue = items[0]; // Store the root value
// Move the last element to the root
items[0] = items[itemCount - 1];
itemCount--;
// Heapify down from the root
int current = 0;
while (true) {
int leftChildIndex = 2 * current + 1;
int rightChildIndex = 2 * current + 2;
int largestIndex = current; // Assume current node is the largest
// Check if left child exists and is larger than current largest
if (leftChildIndex < itemCount && items[leftChildIndex] > items[largestIndex]) {
largestIndex = leftChildIndex;
}
// Check if right child exists and is larger than current largest
if (rightChildIndex < itemCount && items[rightChildIndex] > items[largestIndex]) {
largestIndex = rightChildIndex;
}
// If the largest is not the current node, swap and continue sinking
if (largestIndex != current) {
// Swap items[current] and items[largestIndex]
int temp = items[current];
items[current] = items[largestIndex];
items[largestIndex] = temp;
// Move down to the swapped child
current = largestIndex;
} else {
// Current node is in its correct position, stop
break;
}
}
return maxValue;
}
2. insert() 函數 (插入新節點)
- 處理堆積滿載: 如果
itemCount達到陣列大小 (100),表示堆積已滿,無法插入,應返回false。 - 將新值放入最後位置: 將新值
newValue放在堆積的最後一個可用位置(items[itemCount])。 - 增加計數:
itemCount加 1。
第 2 題10 分
Double hashing is a popular collision resolution scheme that employs two hash functions to determine the location of an item in a hash table. One hash function computes the starting location of an item and the other one specifies the size of probe step.
(a) Explain the benefit of double hashing when resolving collisions.
(b) What is the problem if the hash table size and the probe step size are not relatively prime?
(c) Suggest a solution to the problem.
登入後即可作答並保存紀錄。
【答案】
(a) 雙重雜湊(Double Hashing)藉由第二個雜湊函數 決定探針步長,使初始雜湊值相同但鍵值不同的資料擁有完全獨立且不同的探針序列,能同時有效消除一次聚集(Primary Clustering)與二次聚集(Secondary Clustering),達到極接近均勻雜湊(Uniform Hashing)的優異效能。
(b) 若雜湊表大小 與探針步長 不互質(即 ),則探針序列生成的索引值在模 下對 取模皆同餘於 。這導致探針序列最多只能走訪雜湊表中 個槽位(僅為全表的子集),無法遍歷整個雜湊表;當這 個位置皆被佔用時,探針序列將陷入循環迴路,即使表內其他區域仍有空槽,演算法也無法找到空位,造成插入失敗。
(c) 解決問題的根本方法在於強制確保雜湊表大小 與步長 恆互質,即 。常見實作策略包括:
- 將雜湊表大小 選定為質數(Prime Number),並設計第二個雜湊函數使其輸出滿足 (例如採用 ,其中 為小於 的質數)。由於 為質數且 ,兩者必定互質。
- 若雜湊表大小 設定為 2 的冪次方(),則設計第二個雜湊函數恆產生奇數(例如 或將計算結果與 1 進行按位元或運算),奇數與 2 的冪次方必然互質。
詳解
本題測驗雜湊表(Hash Table)開放定址法(Open Addressing)中,雙重雜湊(Double Hashing)的運作原理、數論性質與設計準則。
雙重雜湊的探針序列公式為:
其中 決定起始雜湊槽位, 決定每次探測的步長(Step size), 為雜湊表大小。
一、子題 (a) 雙重雜湊在解決衝突時的優勢:
在開放定址法中:
- 線性探測(Linear Probing, 步長固定為 1)會導致連續被佔據的槽位聚集成塊,引發一次聚集(Primary Clustering),大幅拉長後續查找時間。
- 二次探測(Quadratic Probing, 步長為 )雖然緩解了一次聚集,但若兩個鍵值計算出的起始位置相同(),兩者將共享完全相同的探針序列,引發二次聚集(Secondary Clustering)。
- 雙重雜湊的關鍵優勢在於:探針步長由第二個獨立的雜湊函數 決定。即使兩個不同的鍵值發生碰撞使得 ,只要 ,兩者產生的探針軌跡便截然不同。這徹底消除了二次聚集,使探針序列分散性大幅提高,是開放定址法中最能逼近理想均勻雜湊(Uniform Hashing)的經典技術。
二、子題 (b) 雜湊表大小與探針步長不互質的問題分析:
設雜湊表大小為 ,步長為 。若 :
探針序列走訪的位置集合為 。
由初等數論同餘性質可知, 必然是 的倍數。