← 回題庫

卷別

資料結構與演算法(A)

選擇

國立臺灣大學 2021 · 考試 · 第 8 題

(5 points) 承上題(陣列 AA 與索引 p,qp, q 初值皆 0,僅能由 f,gf, g 存取)。If functions f(x)f(x) and g()g() are changed as following:

f(x):
    A[q] ← x
    q ← q + 1

g():
    x ← A[p]
    p ← p + 1
    return x

Which data structure is operated by those functions?

  • (A)
    Queue
  • (B)
    Stack
  • (C)
    Hash
  • (D)
    Heap

標準解析

AI 已複查