56 はじめに
56.1 学習目標
- アルゴリズムの概念を理解する.
56.2 アルゴリズムとは
Today, computer science has established itself as the science of algorithms.
– G. Brookshear and D. Brylow, Computer Science: An Overview, 13th ed. Pearson, 2018.
アルゴリズム(algorithm)とは,問題を解決するための手順を指す.これまでに,いくつかのアルゴリズムを紹介してきた.
CPUの命令サイクルは以下のようなアルゴリズムである.
- 命令の取得(fetch)
- 命令の解読(decode)
- 命令の実行(execute)
10進数からn進数への変換もアルゴリズムの一例である.
- 与えられた値をnで割り,商と余りを求める.
- 商が0になるまで繰り返す.
- 商が0になったら,余りを逆順に並べる.
厳密には,アルゴリズムは明確な命令を持ち,有限のステップで実行可能な手順である.
- 明確(Unambiguous):アルゴリズムの各ステップは明確で,解釈の余地がない.
- 有限(Finite):アルゴリズムは有限のステップで完了する.
An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process.
– G. Brookshear and D. Brylow, Computer Science: An Overview, 13th ed. Pearson, 2018.
(An algorithm is a set of) unambiguous instructions for solving a problem or subproblem in a finite amount of time using a finite amount of data.
– N. Dale and J. Lewis, Computer science illuminated, 7th ed. Sudbury, MA: Jones and Bartlett, 2024.