← 回題庫

卷別

資料結構與演算法(A)

選擇

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

(5 points) There is a large enough array AA with indices pp and qq which are initialized by 0, and functions f(x)f(x) and g()g() are defined as follows. Array AA and indices pp and qq can only be accessed in the functions f(x)f(x) and g()g().

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

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 已複查