{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "417f4900-0d8d-4773-853f-b171fe4d909f",
   "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": "47053046-a9d9-4a08-bc94-b415b24e3525",
   "metadata": {},
   "source": "## True or False\n\n**1.** A `List<T>` in C# can grow and shrink dynamically.\n\n```{dropdown} Answer\n**True** — `List<T>` manages its internal array automatically as items are added/removed.\n```\n\n**2.** `Dictionary<K,V>` allows duplicate keys.\n\n```{dropdown} Answer\n**False** — Keys in a `Dictionary` must be unique; adding a duplicate key throws an exception.\n```\n\n**3.** `List<T>.Count` returns the number of elements currently in the list.\n\n```{dropdown} Answer\n**True** — `Count` reflects the current number of items, unlike `Capacity`.\n```\n\n**4.** You can use `foreach` to iterate over both keys and values in a `Dictionary`.\n\n```{dropdown} Answer\n**True** — Iterating a `Dictionary` yields `KeyValuePair<K,V>` entries.\n```\n\n**5.** Removing all elements from a `List` also frees its reserved memory capacity.\n\n```{dropdown} Answer\n**False** — `Clear()` removes elements but keeps the allocated capacity.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "89a59f96-29e9-44cc-b0f4-be0c4893418c",
   "metadata": {},
   "source": "## Multiple Choice\n\n**1.** How do you add an element to a `List<int> nums`?\n\na) nums.Append(5)  \nb) nums.Add(5)  \nc) nums.Insert(0, 5)  \nd) nums.Push(5)\n\n```{dropdown} Answer\n**b) nums.Add(5)** — `Add()` appends an element to the end of the list.\n```\n\n**2.** Which collection type maps unique keys to values?\n\na) List<T>  \nb) Queue<T>  \nc) Dictionary<K,V>  \nd) Stack<T>\n\n```{dropdown} Answer\n**c) Dictionary<K,V>** — `Dictionary<K,V>` is the standard key→value map in C#.\n```\n\n**3.** What method removes the first occurrence of a value from a `List`?\n\na) Delete()  \nb) Pop()  \nc) Remove()  \nd) Clear()\n\n```{dropdown} Answer\n**c) Remove()** — `Remove(value)` finds and removes the first matching element.\n```\n\n**4.** How do you check if a key exists in a `Dictionary<string,int> dict`?\n\na) dict.Contains(key)  \nb) dict.HasKey(key)  \nc) dict.ContainsKey(key)  \nd) dict.Exists(key)\n\n```{dropdown} Answer\n**c) dict.ContainsKey(key)** — `ContainsKey()` returns `true` if the key is present.\n```\n\n**5.** What is the average time complexity of a `Dictionary` key lookup?\n\na) O(n)  \nb) O(log n)  \nc) O(1)  \nd) O(n²)\n\n```{dropdown} Answer\n**c) O(1)** — Hash-based lookup is O(1) average; O(n) worst-case due to collisions.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "329f4572-586c-4845-b2ab-bbe6d15141b2",
   "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
}
