Zum Hauptinhalt springen
ProdukteDesktop-WerkzeugeTASTECADZeichnungsprüfungTASTEFILESDateiverwaltungTASTEFTPDateiübertragungTASTESSHRemote-ArbeitsbereichTASTEZIPKomprimieren und EntpackenTASTEWINMDateiverwaltungEntwicklerwerkzeugeTASTECODEIntegrierte Entwicklungsumgebung für RustTASTESTUDIOIntegrierte Entwicklungs- und TestumgebungTASTEETLDatenintegration (ETL)ServerTASTEREMOTERemote-Desktop-ServerTASTEGEOGeodatenserverTASTEMAILE-Mail-ArbeitsbereichInvestierenTASTESTOCKDesktop-App für automatischen AktienhandelErste SchritteDownloadsDokumentationKaufenAlle Produkte
Marktplatz
Neuigkeiten
TechnikNeuigkeitenEntwickler-News von heuteEntwicklerdokuProgrammiersprachenRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp- & Desktop-FrameworksTauriFlutterReact NativeElectronAlgorithmenAlgorithmus-GrundlagenKernalgorithmenFortgeschrittene AlgorithmenAlgorithmen für die Praxis
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcaseCommunity-Leitfaden
ZusammenarbeitWissenstransferWebsite-AufbauDesktop-App-AufbauRelease- und ZahlungspipelineVertriebspartnerKontakt
DiensteRemote-DesktopIndividuelle Installationspakete
TASTEDEV
Produkte

Desktop-Werkzeuge

TASTECADKomplexe Zeichnungen, mühelos geöffnetTASTEFILESNur die Dateien, die zählen – in BestzeitTASTEFTPDer aufgeräumteste Weg für Ihre DateienTASTESSHDie stärkere Verbindung zu Ihren ServernTASTEZIPSchneller packen, sicherer entpackenTASTEWINMEin tastaturorientierter Dateimanager mit zwei Fenstern

Entwicklerwerkzeuge

TASTECODERust-Apps bearbeiten, bauen, debuggen und testen – alles in einem FensterTASTESTUDIOVom Bearbeiten bis zu Remote-Tests und freigegebenen KI-KorrekturenTASTEETLDaten bewegen, die Werte im Blick

Server

TASTEREMOTEEin Remote-Desktop auf Ihrem eigenen ServerTASTEGEOEin GeoServer-kompatibler Geodatenserver, neu aufgebaut in RustTASTEMAILIhre E-Mail wieder in Ihrer Hand

Investieren

TASTESTOCKAutomatischer Aktienhandel nach Ihren Regeln: wann und was

Erste Schritte

DownloadsNeueste Versionen aller ProdukteDokuSo nutzen Sie jedes ProduktKaufenAbos und DauerlizenzenAlle ProdukteAlle Produkte im Überblick
Alle Produkte
MarktplatzNeuigkeiten
Technik

Neuigkeiten

Entwickler-News von heuteOffizielle Meldungen zu Sprachen, Frameworks, GitHub und KIEntwicklerdokuAnleitungen zu Sprachen, Frameworks und Algorithmen

Programmiersprachen

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App- & Desktop-FrameworksTauriFlutterReact NativeElectron

Algorithmen

Algorithmus-GrundlagenKomplexitätsanalyse · Sortieren · Suchen · Grundlegende Datenstrukturen · Bäume und HeapsKernalgorithmenGraphtraversierung · Kürzeste Wege und minimale Spannbäume · Dynamische Programmierung · Greedy-Algorithmen · Teile und herrsche · BacktrackingFortgeschrittene AlgorithmenZeichenkettenalgorithmen · Mathematik und Zahlentheorie · Bitmanipulation · Segmentbäume · Union-FindAlgorithmen für die PraxisStrategie für Coding-Interviews · LRU-Cache · Rate Limiting · Konsistentes Hashing
Alle Entwicklungsdokumente
Community
ProjekteEntwickler und Projekte entdeckenEntwicklungslogsEntscheidungen und ErkenntnissePromptsWiederverwendbare AnweisungenProbleme mit KI-ToolsProbleme und Workarounds für Claude, Codex, GeminiShowcaseFertige ErgebnisseCommunity-LeitfadenWie wir offen entwickeln
Zusammenarbeit
WissenstransferNative Apps mit Rust und eguiWebsite-Aufbau10 Sprachen, Konten, Dokumentation und DownloadsDesktop-App-AufbauRust und egui, ohne WebViewRelease- und ZahlungspipelineSignatur, MSI, deb, rpm, AppImage, PrüfsummenVertriebspartnerEmpfehlen und 30 % erhaltenKontaktEntwicklung, Partnerschaft, Investition
Dienste
Remote-DesktopIhren Computer im Browser erreichenIndividuelle InstallationspaketeNur nötige Funktionen, Einstellungen vorab
Kaufen
DE
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Anmelden
Anmelden
TASTEDEV

Von kleinen Werkzeugen zu besserer Entwicklung.

support@tastedev.netTASTEDEV unterstützen
ProdukteProduktübersichtKaufenDokuDownloadsMarktplatzSupport
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcase
RichtlinienÜber unsDatenschutzerklärungNutzungsbedingungenAbo-BedingungenRückerstattungCommunity-Richtlinien
KontoAnmeldenRegistrieren
Besucher
Heute
Gestern
Aufrufe gesamt
Firma
GXSOFT
Vertretungsberechtigt
CHOI YOUNG GU
Handelsregisternummer
853-44-00368
Anschrift
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefon
+82-10-4404-1523
E-Mail
whitecalvin@tastedev.net
Datenschutzbeauftragter
CHOI YOUNG GU

© 2026 TASTEDEVProduktinformationen basieren auf verifizierten Entwicklungsquellen.Veröffentlicht · wird verbessert

Teile und herrsche-Dokumentation
Teile und herrsche
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
Diskussionen

Teile und herrsche-Anleitung · 1/6

Divide and Conquer: Core Concepts

Dieses Kapitel ist vorerst nur auf Englisch verfügbar.

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 .

Fragen zu diesem Kapitel?
Nächstes KapitelHow 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 Kommentare

Top-KommentareNeueste zuerst

Anmelden · Melde dich an, um einen Kommentar zu schreiben.