{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "225c1b9b-4170-44f3-a246-3b4436ae9250",
   "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": "234e0ffb-ac4e-4c60-a597-8cd873772c41",
   "metadata": {},
   "source": "## True or False\n\n**1.** Binary search requires the array to be sorted.\n\n```{dropdown} Answer\n**True** — Binary search relies on the sorted order to eliminate half the elements each step.\n```\n\n**2.** Linear search has O(log n) time complexity.\n\n```{dropdown} Answer\n**False** — Linear search checks every element in the worst case — O(n).\n```\n\n**3.** Bubble sort is one of the most efficient algorithms for large datasets.\n\n```{dropdown} Answer\n**False** — Bubble sort is O(n²) — very slow for large inputs.\n```\n\n**4.** Big-O notation describes how an algorithm's runtime scales with input size.\n\n```{dropdown} Answer\n**True** — Big-O characterizes growth rate, not exact runtime.\n```\n\n**5.** Merge sort has O(n log n) average time complexity.\n\n```{dropdown} Answer\n**True** — Merge sort consistently runs in O(n log n) time.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "80be002c-53c7-40d8-af9f-19334514fe5a",
   "metadata": {},
   "source": "## Multiple Choice\n\n**1.** What is the time complexity of binary search?\n\na) O(n)  \nb) O(n²)  \nc) O(log n)  \nd) O(1)\n\n```{dropdown} Answer\n**c) O(log n)** — Each comparison halves the search space, giving O(log n).\n```\n\n**2.** Which sorting algorithm repeatedly swaps adjacent elements if out of order?\n\na) Merge sort  \nb) Quick sort  \nc) Insertion sort  \nd) Bubble sort\n\n```{dropdown} Answer\n**d) Bubble sort** — Bubble sort bubbles the largest unsorted value to its position each pass.\n```\n\n**3.** An O(1) algorithm means:\n\na) It takes exactly one second  \nb) Its runtime grows linearly  \nc) Its runtime is constant regardless of input size  \nd) It contains exactly one loop\n\n```{dropdown} Answer\n**c) Its runtime is constant regardless of input size** — Constant time means performance does not depend on input size.\n```\n\n**4.** Which algorithm recursively divides the array in half and merges results?\n\na) Bubble sort  \nb) Linear search  \nc) Merge sort  \nd) Selection sort\n\n```{dropdown} Answer\n**c) Merge sort** — Merge sort uses divide-and-conquer: split, sort halves, then merge.\n```\n\n**5.** If an algorithm is O(n²), doubling the input size roughly:\n\na) Doubles the runtime  \nb) Has no effect  \nc) Quadruples the runtime  \nd) Halves the runtime\n\n```{dropdown} Answer\n**c) Quadruples the runtime** — (2n)² = 4n² — quadruple growth for doubled input.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "e2564284-e956-4681-95dd-6a253d9adfab",
   "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
}
