資料結構›Ch3 堆疊與佇列
第 11 題/共 28 題
◀ DS 11/28
11. Stack、Queue、Pseudocode判讀
#DS-03-011易StackQueuePseudocode判讀
題組題幹(本題:(b),共 2 小題)點擊展開

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)f(x):

  • p←p+1p \leftarrow p+1
  • A[p]←xA[p] \leftarrow x

g()g():

  • x←A[p]x \leftarrow A[p]
  • p←p−1p \leftarrow p-1
  • return xx

If functions f(x)f(x) and g()g() are changed as following:

f(x)f(x):

  • A[q]←xA[q] \leftarrow x
  • q←q+1q \leftarrow q+1

g()g():

  • x←A[p]x \leftarrow A[p]
  • p←p+1p \leftarrow p+1
  • return xx

Which data structure is operated by those functions?

📄 台大110
跳轉到第題
▤完整推導請見《WH 資工筆記 · 資料結構》Ch3 堆疊與佇列
本章題號 · 1–20 / 28