<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://wiki.cowbloke.com/w/index.php?action=history&amp;feed=atom&amp;title=Pr%C3%A9pa%3AInformatique%2FDiviser_pour_r%C3%A9gner</id>
	<title>Prépa:Informatique/Diviser pour régner - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cowbloke.com/w/index.php?action=history&amp;feed=atom&amp;title=Pr%C3%A9pa%3AInformatique%2FDiviser_pour_r%C3%A9gner"/>
	<link rel="alternate" type="text/html" href="https://wiki.cowbloke.com/w/index.php?title=Pr%C3%A9pa:Informatique/Diviser_pour_r%C3%A9gner&amp;action=history"/>
	<updated>2026-10-06T09:54:41Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki.cowbloke.com/w/index.php?title=Pr%C3%A9pa:Informatique/Diviser_pour_r%C3%A9gner&amp;diff=42&amp;oldid=prev</id>
		<title>CowBloke : Mise en place du wiki de notes</title>
		<link rel="alternate" type="text/html" href="https://wiki.cowbloke.com/w/index.php?title=Pr%C3%A9pa:Informatique/Diviser_pour_r%C3%A9gner&amp;diff=42&amp;oldid=prev"/>
		<updated>2026-09-24T18:51:16Z</updated>

		<summary type="html">&lt;p&gt;Mise en place du wiki de notes&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;Fiche d&amp;#039;exemple : code OCaml et C avec coloration. Modifie-la ou supprime-la librement.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Principe ==&lt;br /&gt;
{{Définition&lt;br /&gt;
|titre=Diviser pour régner&lt;br /&gt;
|contenu=&lt;br /&gt;
On découpe un problème de taille &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; en &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; sous-problèmes de taille &amp;lt;math&amp;gt;n/b&amp;lt;/math&amp;gt;, on les résout récursivement, puis on combine les solutions.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Tri fusion (OCaml) ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ocaml&amp;quot; line&amp;gt;&lt;br /&gt;
let rec scinder = function&lt;br /&gt;
  | [] -&amp;gt; [], []&lt;br /&gt;
  | [x] -&amp;gt; [x], []&lt;br /&gt;
  | x :: y :: q -&amp;gt; let a, b = scinder q in x :: a, y :: b&lt;br /&gt;
&lt;br /&gt;
let rec fusion l1 l2 = match l1, l2 with&lt;br /&gt;
  | [], l | l, [] -&amp;gt; l&lt;br /&gt;
  | x :: q1, y :: q2 -&amp;gt;&lt;br /&gt;
    if x &amp;lt;= y then x :: fusion q1 l2 else y :: fusion l1 q2&lt;br /&gt;
&lt;br /&gt;
let rec tri_fusion = function&lt;br /&gt;
  | ([] | [_]) as l -&amp;gt; l&lt;br /&gt;
  | l -&amp;gt; let a, b = scinder l in fusion (tri_fusion a) (tri_fusion b)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Formule&lt;br /&gt;
|titre=Complexité du tri fusion&lt;br /&gt;
|contenu=&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;C(n)=2\,C(n/2)+\Theta(n)\quad\Longrightarrow\quad C(n)=\Theta(n\log n)&amp;lt;/math&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Recherche dichotomique (C) ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
/* Renvoie un indice de x dans t (trié, de taille n), ou -1. */&lt;br /&gt;
int dichotomie(const int *t, int n, int x) {&lt;br /&gt;
    int g = 0, d = n - 1;&lt;br /&gt;
    while (g &amp;lt;= d) {&lt;br /&gt;
        int m = g + (d - g) / 2;   /* évite le dépassement de g + d */&lt;br /&gt;
        if (t[m] == x) return m;&lt;br /&gt;
        if (t[m] &amp;lt; x) g = m + 1; else d = m - 1;&lt;br /&gt;
    }&lt;br /&gt;
    return -1;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Méthode&lt;br /&gt;
|titre=Prouver la terminaison et la correction&lt;br /&gt;
|contenu=&lt;br /&gt;
* &amp;#039;&amp;#039;Terminaison&amp;#039;&amp;#039; : le variant &amp;lt;math&amp;gt;d-g&amp;lt;/math&amp;gt; est un entier qui décroît strictement à chaque tour tant que &amp;lt;math&amp;gt;g\le d&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;#039;&amp;#039;Correction&amp;#039;&amp;#039; : invariant « si &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; est dans &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;, il est dans &amp;lt;math&amp;gt;t[g..d]&amp;lt;/math&amp;gt; ».&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
On peut aussi écrire du code dans une phrase : &amp;lt;syntaxhighlight lang=&amp;quot;ocaml&amp;quot; inline&amp;gt;List.map (fun x -&amp;gt; x * x) l&amp;lt;/syntaxhighlight&amp;gt;.&lt;/div&gt;</summary>
		<author><name>CowBloke</name></author>
	</entry>
</feed>