本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

分割統治法 ドキュメント
分割統治法
Divide and Conquer: Core ConceptsHow It Works: Step-by-Step TracesImplementation: Inversions and Fast PowerComplexity: Recurrences and the Master TheoremPractice ProblemsDivide and Conquer in the Real World
ディスカッション

分割統治法 ガイド · 1/6

Divide and Conquer: Core Concepts

この章は現在、英語でのみ提供しています。

Divide and conquer is a way of designing algorithms: split a problem into smaller instances of the same problem, solve those instances recursively, and build the answer for the original input from their answers. Merge sort, binary search, fast exponentiation, quickselect, Karatsuba multiplication and the FFT all follow this pattern. Once you recognize it, many problems that seem to need O(n^2) work turn out to be solvable in O(n log n) or better.

The three steps

  1. Divide: split the input into subproblems, usually of roughly equal size. Two halves is the most common choice.
  2. Conquer: solve each subproblem recursively. When a subproblem is small enough (the base case), solve it directly.
  3. Combine: turn the subproblem answers into an answer for the whole input.

Different algorithms put the real work in different steps. In merge sort, dividing is trivial (cut at the middle) and combining, the merge of two sorted halves, does the heavy lifting. In quicksort and quickselect it is the other way around: partitioning around a pivot is the hard part and combining costs nothing.

def max_value(a, lo, hi):
    """Largest element of a[lo:hi] (non-empty), by divide and conquer."""
    if hi - lo == 1:                         # base case: one element
        return a[lo]
    mid = (lo + hi) // 2                     # divide
    left = max_value(a, lo, mid)             # conquer
    right = max_value(a, mid, hi)
    return left if left >= right else right  # combine

print(max_value([3, 9, 2, 7, 5], 0, 5))  # 9

This is no faster than a simple loop, but it shows the skeleton every divide-and-conquer algorithm shares: a base case, a split, recursive calls and a combine step.

Vocabulary

TermMeaning
SubproblemA smaller instance of the same problem, such as sorting half of an array
Base caseAn input small enough to answer directly; it stops the recursion
Recursion treeThe tree of calls: each node is a subproblem, its children are the pieces it splits into
RecurrenceAn equation such as T(n) = 2T(n/2) + O(n) that describes the running time
Combine costThe work done in one call outside its recursive calls
Decrease and conquerA variant that keeps only one subproblem (binary search, fast power, quickselect)

Decrease and conquer

Some algorithms discard all but one subproblem. Binary search compares the target with the middle element and continues in only one half, so the remaining range shrinks geometrically and the total work is .

この章について質問がありますか?
次の章How It Works: Step-by-Step Traces
O(log n)
def binary_search(a, target):
    lo, hi = 0, len(a)              # search in a[lo:hi]
    while lo < hi:
        mid = (lo + hi) // 2
        if a[mid] < target:
            lo = mid + 1            # keep the right half
        else:
            hi = mid                # keep the left half
    return lo if lo < len(a) and a[lo] == target else -1

print(binary_search([1, 3, 5, 7, 9, 11], 7))  # 3

When divide and conquer fits

It works well when the subproblems are independent and combining is cheaper than solving the whole problem from scratch. Good signs:

  • The input splits naturally: halves of an array, high and low digits of a number, left and right sides of a plane.
  • The answer for the whole is the answers for the parts plus some crossing information: pairs that straddle the split, or a subarray that passes through the middle.
  • Subproblems do not share pieces, so each one is solved exactly once.

If subproblems overlap, plain recursion repeats work exponentially. The naive Fibonacci function is the classic warning sign: fib(n - 1) and fib(n - 2) both recompute fib(n - 3) and everything below it. That situation calls for dynamic programming (memoization or a table), not divide and conquer.

calls = 0

def fib(n):
    global calls
    calls += 1
    return n if n < 2 else fib(n - 1) + fib(n - 2)

fib(25)
print(calls)  # 242785 calls for one small answer: overlapping subproblems

Classic examples at a glance

AlgorithmDivideCombineTime
Merge sortCut at the middleMerge two sorted halvesO(n log n)
Counting inversionsCut at the middleCount crossing pairs while mergingO(n log n)
Fast exponentiationHalve the exponentSquare, maybe multiply once moreO(log e) multiplications
QuickselectPartition around a pivotNothing; continue in one sideO(n) expected
KaratsubaSplit numbers into high and low halvesThree products instead of fourO(n^1.585)
Closest pair of pointsSplit the plane with a vertical lineCheck a narrow strip around the lineO(n log n)

Summary

  • Divide and conquer means divide, conquer recursively, combine.
  • The base case stops the recursion; the combine step usually decides the cost.
  • Keeping only one subproblem (decrease and conquer) leads to logarithmic or linear algorithms.
  • Independent subproblems suit divide and conquer; overlapping ones call for dynamic programming.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。