第3章データ構造とアルゴリズム
Greedy Algorithms貪欲アルゴリズム
A greedy algorithm solves combinatorial problems by repeatedly applying a simple rule to select the next element to include in the solution. Unlike brute-force algorithms that solve combinatorial problems by generating all potential solutions, greedy algorithms instead focus on generating just one solution. These algorithms are greedy because they select the next element to include based on the immediate benefit.
英語のヒント
貪欲アルゴリズムは、単純な規則を繰り返し適用し、解に次に含める要素を選ぶことで、組合せ問題を解く。すべての解候補を生成する総当たりアルゴリズムと異なり、貪欲アルゴリズムは、1つの解だけを作ることに注目する。目先の利益に基づいて次の要素を選ぶため、「貪欲」と呼ばれる。
For example, a greedy interval scheduling algorithm might choose to work on the task that takes the least amount of time to complete; in other words, the cheapest way to mark one task as completed (Figure 3.18). If the tasks are scheduled in advance and we can only work on one task at a time, choosing the task that takes the least amount of time to complete might prevent us from completing multiple other (longer) tasks that just so happen to overlap in time. This greedy algorithm does not compute the right output—it finds a solution but not the optimal solution.
英語のヒント
たとえば区間スケジューリングの貪欲アルゴリズムでは、完了に必要な時間が最も短い作業を選ぶことが考えられる。言い換えれば、1つの作業を完了扱いにするために最も安く済む方法である(図3.18)。作業の時間が事前に決まり、同時に1つしか取り組めないなら、所要時間が最も短い作業を選ぶことで、たまたま時間が重なる、ほかの複数の長い作業を完了できなくなることがある。この貪欲アルゴリズムは正しい出力を計算しない。解は見つけるが、最適解ではない。
4 W. D. Haven, “DeepMind’s protein-folding AI has solved a 50-year-old grand challenge of biology,” 2020. https://www.technologyreview.com/2020/11/30/1012712/deepmind-protein-folding-ai-solved-biology-science-drugs-disease/ 5 Google DeepMind, “AlphaFold: A solution to a 50-year-old grand challenge in biology,” 2020." https://deepmind.com/blog/article/ alphafold-a-solution-to-a-50-year-old-grand-challenge-in-biology 6 Google DeepMind, “AlphaFold: Demis Hassabis & John Jumper awarded Nobel Prize in Chemistry,” 2024." https://deepmind.google/discover/blog/demis-hassabis-john-jumper-awarded-nobel-prize-in-chemistry/
4 W. D. Haven「DeepMind’s protein-folding AI has solved a 50-year-old grand challenge of biology(DeepMindのタンパク質折り畳みAIが、生物学の50年来の難題を解いた)」2020年。https://www.technologyreview.com/2020/11/30/1012712/deepmind-protein-folding-ai-solved-biology-science-drugs-disease/5 Google DeepMind「AlphaFold: A solution to a 50-year-old grand challenge in biology(AlphaFold:生物学の50年来の難題への解法)」2020年。https://deepmind.com/blog/article/ alphafold-a-solution-to-a-50-year-old-grand-challenge-in-biology6 Google DeepMind「AlphaFold: Demis Hassabis & John Jumper awarded Nobel Prize in Chemistry(AlphaFold:デミス・ハサビスとジョン・ジャンパーがノーベル化学賞を受賞)」2024年。https://deepmind.google/discover/blog/demis-hassabis-john-jumper-awarded-nobel-prize-in-chemistry/

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 3.18 Greedy interval scheduling will not work if the simple rule repeatedly selects the shortest interval. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図3.18 最短の区間を繰り返し選ぶ単純な規則では、貪欲な区間スケジューリングはうまくいかない。(出典表記:著作権者 Rice University、OpenStax、CC BY 4.0ライセンス)
The majority of greedy algorithms do not always compute the best solution. But there are also certain scenarios in which cleverly crafted greedy algorithms guarantee finding optimal solutions. The problems they solve are formulated to ensure that the greedy algorithm never makes a mistake when repeatedly applying the simple rule to select the next element.
英語のヒント
貪欲アルゴリズムの大半は、いつも最良の解を計算できるわけではない。しかし、巧みに作った貪欲アルゴリズムが最適解を必ず見つける、特定の状況もある。そうした問題は、単純な規則を繰り返して次の要素を選ぶとき、貪欲アルゴリズムが決して誤らないことを保証するように定式化されている。
Consider the municipal broadband planning problem or, more formally, the minimum spanning tree problem, of finding a lowest-cost way to connect all the vertices in a connected graph to each other. If we want to minimize the sum of the selected edge weights, one idea is to repeatedly select the next edge (connections between vertices) with the lowest weight so long as it extends the reach of the network. Or, in the context of the municipal broadband planning problem, we want to ensure that the next-cheapest connection that we choose to build reaches someone who needs access to the Internet (Figure 3.19).
英語のヒント
自治体のブロードバンド計画、より形式的には、連結グラフのすべての頂点を互いにつなぐ最小コストの方法を探す、最小全域木問題を考えよう。選ぶ辺の重みの合計を最小にしたければ、ネットワークの届く範囲を広げる限り、最も重みの小さい辺(頂点間の接続)を次々に選ぶ方法が考えられる。自治体のブロードバンド計画の文脈でいえば、次に構築すると決める最も安い接続が、インターネットへのアクセスを必要とする誰かに届くようにしたいのである(図3.19)。

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 3.19 Municipal broadband planning can be represented as a minimum spanning trees graph problem where the weight of each edge represents the cost of building a connection between two vertices or places. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図3.19 自治体のブロードバンド計画は、最小全域木を求めるグラフの問題として表せる。各辺の重みは、2つの頂点、すなわち場所の間に接続を構築する費用を表す。(出典表記:著作権者 Rice University、OpenStax、CC BY 4.0ライセンス)
GLOBAL ISSUES IN TECHNOLOGY技術をめぐる世界の課題
Municipal Broadband as a Public Utility公共サービスとしての自治体ブロードバンド
The municipal broadband planning problem is just one component of the larger public policy issue of Internet access. As the Internet and the use of digital platforms becomes the standard mode for communication, many people are viewing municipal broadband as a fundamental public utility and civil right. “Municipal broadband can solve access and affordability problems in areas where private ISPs [Internet service providers] have not upgraded networks to modern speeds, fail to provide service to all residents, and/or charge outrageous rates.”7
英語のヒント
自治体のブロードバンド計画は、インターネットへのアクセスという、より大きな公共政策の問題の1つの構成要素である。インターネットとデジタルプラットフォームの利用が標準的な通信手段になるにつれ、多くの人々は、自治体のブロードバンドを基本的な公共サービスであり、市民の権利だと考えるようになっている。「民間のISP[インターネットサービスプロバイダー]が、ネットワークを現代的な速度へ更新せず、すべての住民にサービスを提供せず、かつ/または法外な料金を請求する地域では、自治体ブロードバンドは、アクセスと負担可能な料金の問題を解決できる。」7
While a minimum spanning tree algorithm can solve the municipal broadband planning problem, the challenges of deploying municipal broadband for everyone is more political rather than algorithmic. But other algorithms can also directly contribute to the way in which society understands the problem. For example, we might use algorithms to better visualize and understand who currently has access to affordable and reliable high-speed Internet. We can design algorithms to ensure equitable distribution, deployment, and integration of new technologies so that marginalized communities can realize the positive economic benefits first. Or we can reconfigure the minimum spanning trees problem model to take specifically account for expanding network access in an equitable fashion.
英語のヒント
最小全域木のアルゴリズムで、自治体のブロードバンド計画の問題は解ける。しかし、すべての人にサービスを行き渡らせる課題は、アルゴリズムというより政治の問題である。それでも、ほかのアルゴリズムが、社会による問題の理解の仕方に直接貢献することもある。たとえば、現在、安価で信頼できる高速インターネットを誰が利用できるかを、よりよく可視化して理解するために、アルゴリズムを使える。新技術の配分、導入、統合を公平に行い、周縁に追いやられた地域社会がプラスの経済的効果を先に実現できるようにするアルゴリズムも設計できる。あるいは、公平な形でネットワークへのアクセスを拡大することを具体的に考慮するように、最小全域木問題のモデルを組み替えることもできる。
7 J. Broken, “Victory for municipal broadband as Wash. state lawmakers end restrictions,” 2021. Ars Technica, https://arstechnica.com/tech-policy/2021/04/victory-for-municipal-broadband-as-wash-state-lawmakers-end-restrictions
7 J. Broken「Victory for municipal broadband as Wash. state lawmakers end restrictions(ワシントン州の議員が制限を撤廃し、自治体ブロードバンドに勝利)」2021年。Ars Technica。https://arstechnica.com/tech-policy/2021/04/victory-for-municipal-broadband-as-wash-state-lawmakers-end-restrictions
Computer scientists have designed algorithms that repeatedly apply this simple rule to find an optimal minimum spanning tree:
コンピューター科学者は、この単純な規則を繰り返し適用して、最適な最小全域木を求めるアルゴリズムを設計してきた。
• Kruskal’s algorithm, a greedy algorithm which sorts the list of edges in the graph by weight.
英語のヒント
・クラスカル法。グラフの辺のリストを重みで整列する貪欲アルゴリズム。
• Prim’s algorithm, a greedy algorithm that maintains a priority queue of vertices in the graph ordered by connecting edge weight.
英語のヒント
・プリム法。グラフの頂点を、接続する辺の重みの順に並べた優先度付きキューを保持する貪欲アルゴリズム。
For most problems, greedy algorithms will not produce the best solution. Instead, algorithm designers typically turn to another algorithmic paradigm called dynamic programming. Still, greedy algorithms provide a useful baseline starting point for understanding problems and designing baseline algorithms for generating potential solutions.
英語のヒント
ほとんどの問題で、貪欲アルゴリズムは最良の解を生まない。そのため設計者は通常、動的計画法という別のパラダイムを使う。それでも、貪欲アルゴリズムは、問題を理解し、解候補を生成する基本的なアルゴリズムを設計するための、有用な出発点となる。