{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "762632f9-4e1c-4a40-894a-1e2ff6017612",
   "metadata": {},
   "source": "# Preview Questions\n\nComplete these questions **before** class to prepare for the chapter.\nUse the dropdowns to check your answers.\n"
  },
  {
   "cell_type": "markdown",
   "id": "82564caa-c6a6-4742-9532-a5bc027194d9",
   "metadata": {},
   "source": "## True or False\n\n**1.** A stack follows Last-In, First-Out (LIFO) order.\n\n```{dropdown} Answer\n**True** — The most recently pushed item is the first to be popped.\n```\n\n**2.** A queue follows Last-In, First-Out (LIFO) order.\n\n```{dropdown} Answer\n**False** — A queue is First-In, First-Out (FIFO).\n```\n\n**3.** In C#, `Stack<T>.Pop()` removes and returns the top element.\n\n```{dropdown} Answer\n**True** — `Pop()` both removes and returns the top item.\n```\n\n**4.** A linked list provides O(1) random access by index.\n\n```{dropdown} Answer\n**False** — Linked list access by index is O(n); arrays provide O(1) access.\n```\n\n**5.** `Queue<T>.Enqueue()` adds an element to the back of the queue.\n\n```{dropdown} Answer\n**True** — Elements enter at the back and leave from the front.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "3cc11450-a84d-4017-91be-024b18f28f1f",
   "metadata": {},
   "source": "## Multiple Choice\n\n**1.** Which data structure is best for implementing an 'undo' feature?\n\na) Queue  \nb) Stack  \nc) List  \nd) Dictionary\n\n```{dropdown} Answer\n**b) Stack** — LIFO order means the last action is the first to be undone.\n```\n\n**2.** What does `Queue<T>.Dequeue()` do?\n\na) Adds to the back  \nb) Peeks at the front  \nc) Removes and returns the front element  \nd) Clears the queue\n\n```{dropdown} Answer\n**c) Removes and returns the front element** — `Dequeue()` removes and returns the element at the front.\n```\n\n**3.** In a singly linked list, each node contains:\n\na) Only a value  \nb) Only a pointer  \nc) A value and a pointer to the next node  \nd) Two pointers\n\n```{dropdown} Answer\n**c) A value and a pointer to the next node** — Each node stores data and a reference to the next node.\n```\n\n**4.** Which collection processes tasks in the order they arrive (FIFO)?\n\na) Stack  \nb) Dictionary  \nc) Queue  \nd) Array\n\n```{dropdown} Answer\n**c) Queue** — Queue maintains arrival order — first in, first out.\n```\n\n**5.** What is the time complexity of inserting at the front of a linked list?\n\na) O(n)  \nb) O(log n)  \nc) O(1)  \nd) O(n²)\n\n```{dropdown} Answer\n**c) O(1)** — Insertion at the head only updates one pointer, so it is O(1).\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "9a179ec5-684a-4945-906d-28ae35bb71b0",
   "metadata": {},
   "source": "```{rubric} Footnotes\n```\n"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
