抽象データ型:操作契約
導入済み| English | 意味 |
|---|---|
| stack/stæk/ | スタック |
| queue/kjuː/ | キュー |
What would explain this observation?
- A waiting-line simulation needs the oldest pending item first. A stack 栈 gives the most recent item first, so the operation contract matters.
- Start with a prediction. State the quantities or features you would compare, then decide what evidence could distinguish two explanations.
Build the model
- An abstract data type specifies values and operations independently of a particular implementation. A stack is last in, first out; a queue 队列 is first in, first out. A collection interface needs defined behaviour for empty and invalid operations.
- stack: A last-in-first-out abstract data type; queue: A first-in-first-out abstract data type.
通常の先着順の待ち行列をモデル化する構造はどれか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
待機列は先来先サービス(FIFO)であり、これがキューの契約そのものです。後端への追加(enqueue)、前端からの取り出し(dequeue)を行います。スタックは後入先出(LIFO)であり、契約を持たない構造は信頼できるものをモデル化しません。
各専門用語を正確な意味と対応させよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
関連する物理量やプロセスを区別するために定義を使用せよ。
Choose evidence that can test it
- Choose the structure for the required access pattern. Complexity depends on implementation and assumptions: removing the first item from a shifting array differs from advancing a head pointer in a queue.
- Trace operation sequences by hand, then compare a program with the expected states. Test empty, singleton and repeated operations. State overflow behaviour if capacity is fixed.
この場合、調査やモデルをより妥当にする2つの習慣は何か。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
条件や仮定を明記することで他者が正確に再現でき、根拠となる証拠を記録することで結論を検証できます。相反する結果を隠すと、誤った結論を疑う証拠を失いますし、単一の測定でより広い主張を成立させることはできません。
Work from known quantities
- State the known values and their units. Choose the relation because its assumptions fit this case, then rearrange before substitution.
- Known: enqueue A, B and C, then dequeue twice. A and B leave; C remains. After enqueue D there are two pending items, C then D. The same pushes on a stack would remove C then B.
A queue starts empty, receives 7 items and removes 4. Find the number remaining. Use the same sequence: known quantities → model → relation → substitution → unit and interpretation.
キューが空の状態から始まり、7 個のアイテムを受け取り、4 個を削除しました。残りのアイテム数を求めください。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
結果は3個です。既知:空のキュー;7の追加操作;4の削除操作。残りは 7 - 4 = 3 個です。到着順に、直近3回の到着者はまだ待機しています。
Check the conclusion and its limits
- An ADT is not a specific memory layout. A queue does not sort by priority unless its contract defines a priority queue.
- Return to the original observation. Explain what the result supports, which conditions it assumes, and one way to test a competing explanation.
Every queue automatically sorts items by priority. This claim is false: An ordinary queue releases items strictly in arrival order. Serving by importance is a PRIORITY queue - a different contract that must be stated explicitly.
Abstract data types: an operation contract: Choose the structure for the required access pattern. Complexity depends on implementation and assumptions: removing the first item from a shifting array differs from advancing a head pointer in a queue.
すべてのキューは自動的に優先度順でアイテムをソートする。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
通常のキューは厳密に到着順でアイテムを処理します。重要度に基づく処理はPRIORITY(優先順位)キューであり、明確に定義される異なる契約です。
最後に入力された要素が最初に出力される抽象データ型: 技術用語を書け。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
スタックとは、ラストイン・ファーストアウトの抽象データ型を意味する。