Pythonによるデータ構造とアルゴリズム分析 (第2版)
本書は、Pythonを用いてデータ構造とアルゴリズムを解説する古典的な教科書です。Pythonの基礎復習、アルゴリズム解析(オーダー記法)、基本的なデータ構造(スタック、キュー、リスト)、再帰、探索とソート、木およびグラフアルゴリズムについて扱います。実践的なコードリストを通じて、読者がPythonを使ってさまざまな抽象データ型を効率的に実装する方法を理解するのに役立ちます。
コース概要
📚 コンテンツ概要
本書は、Python を用いたデータ構造とアルゴリズムの古典的教科書です。Python の基礎復習、アルゴリズム解析(オーダー記法)、基本的なデータ構造(スタック、キュー、リスト)、再帰、探索とソート、木およびグラフアルゴリズムを網羅しています。実践的なコード例を通じて、読者が Python を活用してさまざまな抽象データ型を効率的に実装する方法を理解する手助けとなります。
データ構造とアルゴリズムを本質的に理解できなければ、真の意味で Python をマスターすることはできません。
著者: ブラッドリー・ミラー(アメリカ・ルーテル大学名誉教授), デイビッド・ランアム(IBM Watson 認知ソフトウェアエンジニア)
謝辞: 第1版の豊富なフィードバックと新版に向けた新しい素材提供に貢献してくれた同僚のスティーブ・ハ버ダーに感謝します。また、各地の読者から誤植や意見をメールでご連絡いただき、誠にありがとうございました。ディコラ市にある Java John's カフェのマリー、ボブらスタッフの方々にも感謝申し上げます。休暇中に店舗の「常駐ライター」として活動させていただいたことに感謝いたします。さらに、Franklin, Beedle & Associates 出版社の皆様(特にジム・ライジーとトム・サムナー)との愉快な協力に感謝します。最後に、私たち二人の妻であるジェーン・ミラーとブレンドア・ランアムに心からの感謝を捧げます。彼女たちの愛と支えがあって、ようやく本書が完成しました。
🎯 学習目標
- コンピュータサイエンス、アルゴリズム、プログラミングの関係性を理解し、抽象データ型(ADT)と情報隠蔽の概念を習得する。
- Python の組み込み集合データ型(リスト、タプル、セット、辞書)および制御構造(ループ、分岐、例外処理)を熟练に使用できる。
- Python のオブジェクト指向プログラミングの核となる内容を習得:クラス定義、コンストラクタ、演算子オーバーロード(分数の加算など)、ユークリッドの互除法の応用、深さコピーと浅さコピーの違い。
- アルゴリズムの多様な対比:異序語検出の4つの手法(カウント、並べ替え、ブルートフォース、カウンティング)とそれぞれの時間計算量を説明できる。
- Python のコンテナ性能の定量的理解:リスト(List)と辞書(Dict)の主要操作における大 O 効率を把握し、
pop()とpop(i)のパフォーマンス差を区別できる。 - パフォーマンス検証能力:
timeitモジュールを用いて実験を設計し、理論的な複雑さと実際の実行時間の整合性を検証できる。 - 線形データ構造(スタック、キュー、デュアルキューやリスト)の論理的特徴を理解し、区別できる。
- Python の基本集合(例:リスト)を使って、独自のスタック、キュー、デュアルキューや他のデータ構造を実装できる。
- スタックが式処理(中置記法 → 後置記法、後置記法の評価)やキューがシステムシミュレーション(プリンタシミュレーション)においてどのように利用されるかを理解できる。
- 再帰の核心三原則を習得:基本ケース、状態の変化、自己呼び出しを含む再帰関数を正確に識別し、実装できる。
レッスン 共 8 课时 · 预计 24.0h
レッスン
Lesson
This lesson introduces the core principles of computer science, focusing on problem-solving through algorithms, procedural abstraction, and Python’s object-oriented nature. Students will learn to manage complexity by leveraging Python’s dynamic variable references, efficient built-in data structures, and robust error-handling techniques to build reliable, scalable software.
本课程深入探讨了算法分析的核心工具——大O记法,通过异序词检测案例展示了从暴力法到计数法的性能优化过程。学习重点在于理解不同操作(如列表索引与pop操作)的复杂度差异,并掌握如何通过空间换时间及选择合适的数据结构来提升程序效率。
This lesson introduces linear data structures and the concept of Abstract Data Types (ADTs), focusing on the stack as a fundamental LIFO (Last-In, First-Out) structure. Students will learn to implement stacks in Python and apply them to complex tasks, including converting infix expressions to postfix notation and evaluating those expressions efficiently.
本课程深入探讨了递归算法的核心原理,重点讲解了递归三原则(基准情况、状态改变、自我调用)以及递归与系统调用栈之间的内在联系。通过进制转换、汉诺塔及动态规划等案例,学生将学习如何将复杂问题拆解为自相似的子问题,并掌握从递归思维向高效动态规划算法的进阶转换。
This lesson explores fundamental search and retrieval algorithms, progressing from $O(n)$ sequential search to the $O(\log n)$ efficiency of binary search and the $O(1)$ potential of hash tables. Students learn to optimize data access through divide-and-conquer strategies, sophisticated hash function design, and collision-handling techniques to build efficient, dictionary-like data structures.
This lesson explores the hierarchical and recursive nature of tree data structures, covering fundamental terminology, implementation methods like nested lists and object-oriented references, and the construction of expression trees. It also introduces essential tree traversal algorithms—preorder, inorder, and postorder—and explains how these recursive patterns are applied to tasks like file system analysis and AVL tree balancing.
This lesson introduces graph theory as a powerful tool for modeling real-world problems by abstracting entities as vertices and relationships as edges. Students will learn to implement graphs using adjacency lists, compare storage efficiency, and master the Breadth-First Search (BFS) algorithm to solve pathfinding and state-space challenges.
This lesson explores the memory efficiency of Python's ArrayList, explaining how amortized analysis ensures $O(1)$ performance for append operations through strategic over-allocation. It also covers the mathematical foundations of RSA encryption, demonstrating how modular exponentiation and divide-and-conquer algorithms optimize complex calculations for secure data processing.