{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ch14-title",
   "metadata": {},
   "source": [
    "# Abstract Data Structures"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch14-overview",
   "metadata": {},
   "source": [
    "Abstract data structures describe how collections behave before we decide exactly how to implement them.\n",
    "\n",
    "- Abstract data types define supported operations and expected behavior\n",
    "- Concrete data structures store values in specific ways\n",
    "- Operation costs guide structure choice\n",
    "- Stacks and queues model order-sensitive workflows\n",
    "- Trees and graphs model hierarchical and relational data\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "video",
   "metadata": {},
   "source": [
    "<h2>Chapter Video</h2>\n",
    "\n",
    "The following overview introduces the main data-structure families: arrays/lists, linked lists, stacks, queues, trees, graphs, and hash tables. This chapter implements stacks, queues, trees, and graphs; Chapter 7 explains the hashing behind `dict` and `set`, and linked lists appear only in the video.\n",
    "\n",
    "```{raw} html\n",
    "<iframe width=\"100%\" height=\"400\" src=\"https://www.youtube-nocookie.com/embed/SuCGoHVoIag\" title=\"Data Structures Explained: Arrays, Stacks, Graphs & More | Computer Science Fundamentals\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen referrerpolicy=\"strict-origin-when-cross-origin\"></iframe>\n",
    "```\n",
    "\n",
    "> *[Data Structures Explained: Arrays, Stacks, Graphs & More | Computer Science Fundamentals (11:13)](https://youtube.com/watch?v=SuCGoHVoIag) by WhiteboardDoodles*\n",
    ">\n",
    "> Hosted on YouTube; property of its original creator, embedded here for educational reference only."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch14-goals",
   "metadata": {},
   "source": [
    "<h2>Learning Objectives</h2>\n",
    "\n",
    "By the end of this chapter, you will be able to:\n",
    "\n",
    "1. Explain the difference between an abstract data type and a concrete implementation\n",
    "2. Compare common operations such as insertion, deletion, lookup, and traversal\n",
    "3. Use stacks and queues to model order-sensitive workflows\n",
    "4. Represent hierarchical data with trees and relationship data with graphs\n",
    "5. Choose a data structure based on clarity, constraints, and performance tradeoffs\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch14-flow",
   "metadata": {},
   "source": [
    "<h2>Chapter Flow</h2>\n",
    "\n",
    "```{container} chapter-flow\n",
    "1. {doc}`1301-adt-basics`\n",
    "2. {doc}`1302-stacks-queues`\n",
    "3. {doc}`1303-trees-graphs`\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "glossary",
   "metadata": {},
   "source": [
    "<h2>Glossary</h2>\n",
    "\n",
    "| # | Term | Explanation |\n",
    "|---:|---|---|\n",
    "| 1 | Abstract data type | A behavior-focused description of a collection and its operations. |\n",
    "| 2 | Concrete implementation | The storage and code choices used to perform an abstract data type's behavior. |\n",
    "| 3 | Operation | An action a data structure supports, such as access, search, insert, or delete. |\n",
    "| 4 | Access | Retrieving an item from a data structure, often by position or key. |\n",
    "| 5 | Search | Looking through a data structure to find a value or relationship. |\n",
    "| 6 | Insert | Adding a new item to a data structure. |\n",
    "| 7 | Delete | Removing an item from a data structure. |\n",
    "| 8 | Tradeoff | A design choice where improving one operation or representation can make another cost worse. |\n",
    "| 9 | Stack | A last-in, first-out collection. |\n",
    "| 10 | LIFO | Last in, first out, the access rule used by stacks. |\n",
    "| 11 | Push | The stack operation that adds an item to the top. |\n",
    "| 12 | Pop | The stack operation that removes and returns the top item. |\n",
    "| 13 | Peek | The stack operation that looks at the top item without removing it. |\n",
    "| 14 | Queue | A first-in, first-out collection. |\n",
    "| 15 | FIFO | First in, first out, the access rule used by queues. |\n",
    "| 16 | Enqueue | The queue operation that adds an item to the back. |\n",
    "| 17 | Dequeue | The queue operation that removes and returns the front item. |\n",
    "| 18 | Tree | A hierarchical structure with a root and child nodes. |\n",
    "| 19 | Binary tree | A tree in which each node has at most two children, called the left child and the right child. |\n",
    "| 20 | Tree traversal | Visiting every node of a tree once in a fixed order: preorder (node first), inorder (node between its subtrees), or postorder (node last). |\n",
    "| 21 | Binary search tree | A binary tree in which every node's left subtree holds smaller values and its right subtree holds larger values. |\n",
    "| 22 | Graph | A structure made of nodes and edges representing relationships. |\n",
    "| 23 | Traversal | A systematic process for visiting nodes in a data structure. |\n",
    "| 24 | `deque` | A double-ended queue from `collections` that adds and removes items at either end in O(1) time. |\n",
    "| 25 | Node | One item in a tree or graph, holding a value and links to related items. |\n",
    "| 26 | Root | The single node at the top of a tree, the only node with no parent. |\n",
    "| 27 | Leaf | A tree node that has no children. |\n",
    "| 28 | Subtree | The smaller tree formed by a node and all of its descendants. |\n",
    "| 29 | Tree height | The number of levels on the longest path from the root down to a leaf. |\n",
    "| 30 | Degenerate tree | A tree in which every node has at most one child, so its height equals its number of nodes. |\n",
    "| 31 | Edge | A connection between two nodes in a graph. |\n",
    "| 32 | Adjacency list | A graph representation that maps each node to a list of its neighbors, commonly a `dict` of lists in Python. |\n",
    "| 33 | Breadth-first search | A graph traversal that uses a queue to visit all nearby nodes before moving farther away. |\n",
    "| 34 | Depth-first search | A graph traversal that uses a stack or recursion to follow one path as far as possible before backing up. |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1400-slides",
   "metadata": {},
   "source": [
    "<h2><a href=\"overview.html\" target=\"_blank\" style=\"color: var(--pst-color-link, #176de8);\">Chapter Overview Slides</a></h2>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
