{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "title",
   "metadata": {},
   "source": [
    "# Assignments\n",
    "\n",
    "These assignments reinforce the main Chapter 14 ideas: matching structures to operations, implementing stacks and queues, and representing relationships with trees and graphs."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "preview",
   "metadata": {},
   "source": [
    "## Preview Questions\n",
    "\n",
    "1. What is the difference between an abstract data type and a concrete implementation?\n",
    "2. Give one real-world example that behaves like a stack.\n",
    "3. Give one real-world example that behaves like a queue.\n",
    "4. Why is a dictionary a natural way to represent an adjacency list?\n",
    "5. When would a tree be a better model than a graph?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab",
   "metadata": {},
   "source": [
    "## Lab Assignment\n",
    "\n",
    "Build a small task-management simulation.\n",
    "\n",
    "Requirements:\n",
    "\n",
    "- Use a queue for incoming tasks.\n",
    "- Use a stack for undo history.\n",
    "- Use a dictionary to store task metadata by task ID.\n",
    "- Demonstrate adding three tasks, completing two tasks, undoing one action, and looking up one task by ID.\n",
    "- Include short comments explaining why each structure was chosen."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "homework",
   "metadata": {},
   "source": [
    "## Homework Questions\n",
    "\n",
    "1. Implement a function `is_balanced(text)` that checks whether parentheses in a string are balanced.\n",
    "2. Create a queue-based simulation of a customer-service line with at least five customers.\n",
    "3. Represent a small company hierarchy as a tree and print it with indentation.\n",
    "4. Represent course prerequisites as a graph using a dictionary.\n",
    "5. Write a short paragraph comparing BFS and DFS. Include one situation where each would be useful."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "review",
   "metadata": {},
   "source": [
    "## Review Questions\n",
    "\n",
    "1. What operation makes a stack different from a queue?\n",
    "2. Why is `collections.deque` better than a list for queue behavior?\n",
    "3. What does a node store in a linked structure?\n",
    "4. What is the root of a tree?\n",
    "5. What are nodes and edges in a graph?\n",
    "6. Which traversal uses a queue: BFS or DFS?\n",
    "7. Which traversal can naturally use a stack: BFS or DFS?"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
