From: Martin Mares Date: Sun, 20 Jan 2008 20:40:01 +0000 (+0100) Subject: Pripsan odstavec o implementaci Goldberg se zvedanim nejvyssiho vrcholu, X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=ef9ea0e2dba1f4450881e763524cf9f2fbc100bb;p=ads2.git Pripsan odstavec o implementaci Goldberg se zvedanim nejvyssiho vrcholu, opraven obrazek separatoru. --- diff --git a/5-sortnet/5-sortnet.tex b/5-sortnet/5-sortnet.tex index 7df746d..02f0cfb 100644 --- a/5-sortnet/5-sortnet.tex +++ b/5-sortnet/5-sortnet.tex @@ -87,8 +87,20 @@ p $\O(N^2\sqrt M)$. \qed -%\s{Implementace:} -%????? +\s{Implementace:} +Narozdíl od pùvodní verze algoritmu si ve verzi se zvedáním nejvy¹¹ího +vrcholu nebudeme pamatovat seznam vrcholù s~kladným pøebytkem, ale +setøídìný seznam pøihrádek. V~ka¾dé pøihrádce budou jen vrcholy +s~pøebytkem s~urèitou vý¹kou. Vyhledání nejvy¹¹ího vrcholu tedy +zvládneme v konstantním èase, stejnì pro zvý¹ení vrcholu nám staèí +$\O(1)$ (buï vrchol pøesuneme do vedlej¹í pøihrádky, nebo pro nìj +zalo¾íme novou). Pøevádíme-li pøebytek do vrcholu, kde pøedtím nebyl, +pak musí mít vý¹ku o~$1$ ni¾¹í, ne¾ vrchol, ze kterého pøebytek +pøevádíme (jinak by existovala nenasycená hrana se spádem dva, co¾ +nejde). Najít (pøípadnì vytvoøit) pøihrádku novì vzniklému vrcholu +s~pøebytkem tak také stihneme v~konstantním èase. +Pro zvednutí nám tedy stále staèí èas $\O(N)$ a libovolné +pøevedení pøebytku zvládneme v~$\O(1)$. \medskip \h{Tøídìní} diff --git a/5-sortnet/sortnet.0 b/5-sortnet/sortnet.0 index 8fe9deb..a2087ec 100644 --- a/5-sortnet/sortnet.0 +++ b/5-sortnet/sortnet.0 @@ -1,7 +1,7 @@ %!PS %%BoundingBox: -1 19 60 100 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %*Font: cmr10 9.96265 9.96265 61:c08c01 %%EndProlog diff --git a/5-sortnet/sortnet.1 b/5-sortnet/sortnet.1 index f1d44e1..5ec51d9 100644 --- a/5-sortnet/sortnet.1 +++ b/5-sortnet/sortnet.1 @@ -1,7 +1,7 @@ %!PS %%BoundingBox: -15 -1 128 166 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %*Font: cmr10 9.96265 9.96265 31:f80000000000000001 %%EndProlog diff --git a/5-sortnet/sortnet.2 b/5-sortnet/sortnet.2 index 29173ef..25656e7 100644 --- a/5-sortnet/sortnet.2 +++ b/5-sortnet/sortnet.2 @@ -1,7 +1,7 @@ %!PS %%BoundingBox: -6 42 119 166 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %*Font: cmr10 9.96265 9.96265 31:f80000000000000001 %%EndProlog diff --git a/5-sortnet/sortnet.3 b/5-sortnet/sortnet.3 index 8f48ec8..e30c8cd 100644 --- a/5-sortnet/sortnet.3 +++ b/5-sortnet/sortnet.3 @@ -1,7 +1,7 @@ %!PS -%%BoundingBox: -6 -1 295 95 +%%BoundingBox: -6 -1 266 95 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %*Font: cmmi10 9.96265 9.96265 3a:8000000000000002 %*Font: cmr7 6.97385 6.97385 30:e @@ -31,8 +31,6 @@ newpath 226.77124 0 moveto 226.77124 85.03922 lineto stroke newpath 255.11765 0 moveto 255.11765 85.03922 lineto stroke -newpath 283.46405 0 moveto -283.46405 85.03922 lineto stroke 0 0.3985 dtransform truncate idtransform setlinewidth pop newpath 0 70.86601 moveto 141.73203 70.86601 lineto stroke @@ -87,21 +85,21 @@ gsave fill grestore stroke (:) cmmi10 9.96265 fshow 143.94592 88.03922 moveto (:) cmmi10 9.96265 fshow -244.46024 90.36383 moveto +216.11383 90.36383 moveto (x) cmmi10 9.96265 fshow -250.15413 88.86943 moveto +221.80772 88.86943 moveto (n) cmmi7 6.97385 fshow -255.07904 88.86943 moveto +226.73264 88.86943 moveto (\000) cmsy7 6.97385 fshow -261.30563 88.86943 moveto +232.95923 88.86943 moveto (2) cmr7 6.97385 fshow -272.80664 90.36383 moveto +244.46024 90.36383 moveto (x) cmmi10 9.96265 fshow -278.50053 88.86943 moveto +250.15413 88.86943 moveto (n) cmmi7 6.97385 fshow -283.42545 88.86943 moveto +255.07904 88.86943 moveto (\000) cmsy7 6.97385 fshow -289.65204 88.86943 moveto +261.30563 88.86943 moveto (1) cmr7 6.97385 fshow showpage %%EOF diff --git a/5-sortnet/sortnet.4 b/5-sortnet/sortnet.4 index 238bd3e..e6ad3e1 100644 --- a/5-sortnet/sortnet.4 +++ b/5-sortnet/sortnet.4 @@ -1,7 +1,7 @@ %!PS %%BoundingBox: -1 -1 213 100 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %%EndProlog %%Page: 1 1 diff --git a/5-sortnet/sortnet.5 b/5-sortnet/sortnet.5 index 7af4c41..6877616 100644 --- a/5-sortnet/sortnet.5 +++ b/5-sortnet/sortnet.5 @@ -1,7 +1,7 @@ %!PS %%BoundingBox: -1 -5 213 114 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %*Font: cmr10 9.96265 9.96265 10:98000000000020000000585328 %*Font: cmmi10 9.96265 9.96265 42:800040000008 diff --git a/5-sortnet/sortnet.6 b/5-sortnet/sortnet.6 index e9d168e..61b14d5 100644 --- a/5-sortnet/sortnet.6 +++ b/5-sortnet/sortnet.6 @@ -1,7 +1,7 @@ %!PS %%BoundingBox: -1 -1 213 100 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %*Font: cmmi10 9.96265 9.96265 4d:8 %*Font: cmr7 6.97385 6.97385 32:a2 diff --git a/5-sortnet/sortnet.7 b/5-sortnet/sortnet.7 index 661fac6..94619ca 100644 --- a/5-sortnet/sortnet.7 +++ b/5-sortnet/sortnet.7 @@ -1,7 +1,7 @@ %!PS %%BoundingBox: 9 5 191 130 %%Creator: MetaPost -%%CreationDate: 2008.01.14:1141 +%%CreationDate: 2008.01.20:2138 %%Pages: 1 %*Font: cmr10 9.96265 9.96265 13:80000086000000000002247de1 %*Font: cmmi10 9.96265 9.96265 6b:9 diff --git a/5-sortnet/sortnet.mp b/5-sortnet/sortnet.mp index 3aabd36..081f9f4 100644 --- a/5-sortnet/sortnet.mp +++ b/5-sortnet/sortnet.mp @@ -278,7 +278,6 @@ draw(z70--z76); draw(z80--z86); draw(z90--z96); draw(z100--z106); -draw(z110--z116); drawarrow(z15--z65); drawarrow(z24--z74); drawarrow(z33--z83); @@ -289,8 +288,8 @@ label.top(btex $x_0$ etex,z16); label.top(btex $x_1$ etex,z26); label.top(btex $x_2$ etex,z36); label.top(btex \dots etex,z66); -label.top(btex $x_{n-2}$ etex,z106); -label.top(btex $x_{n-1}$ etex,z116); +label.top(btex $x_{n-2}$ etex,z96); +label.top(btex $x_{n-1}$ etex,z106); endfig;