Лекция 1. Амортизационный анализ (amortized analysis)

Download Лекция 1. Амортизационный анализ (amortized analysis)

Post on 18-Jan-2017

569 views

Category:

Software

2 download

Embed Size (px)

TRANSCRIPT

<ul><li><p> 1 (amortized analysis)</p><p>E-mail: mkurnosov@gmail.comWWW: www.mkurnosov.net</p><p> () , 2015</p></li><li><p>22</p><p>1. , </p><p>2. , </p><p> , </p><p>( , </p><p>)</p><p>3. </p><p> :</p><p>O, , </p><p>n, m</p><p>T(n, m) = 2n2 + 4log2m</p><p>T(n, m) = O(2n2 + 4log2m) = O(max{n2, log2m})</p></li><li><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>3</p><p> ( )</p></li><li><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>4</p><p> ( )</p><p>1 </p></li><li><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>5</p><p> ( )</p><p>1 </p><p>2 ( worst case)</p></li><li><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>6</p><p> ( )</p><p>1 </p><p>2 ( worst case)</p><p>4 </p></li><li><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>7</p><p> ( )</p><p>1 </p><p>2 ( worst case)</p><p>4 </p><p>i = 1, j = 2 to n, n 1 .i = 2, j = 3 to n, n 2 .i = 3, j = 4 to n, n 3 .i = n 1, j = n to n, 1 .</p></li><li><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>8</p><p> ( )</p><p>1 </p><p>2 ( worst case)</p><p>4 </p><p>T(n) = (n 1) + 4 (n 1) + 2((n 1) + (n 2) + + 1) = ?</p></li><li><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>9</p><p> ( )</p><p>1 </p><p>2 ( worst case)</p><p>4 </p><p>T(n) = (n 1) + 4 (n 1) + 2((n 1) + (n 2) + + 1) = ?</p></li><li><p>T(n) = 5n 5 + 2((n2 n) / 2) = n2 + 4n 5</p><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>10</p><p> ( )</p><p>1 </p><p>2 ( worst case)</p><p>4 </p></li><li><p>T(n) = n2 + 4n 5 = O(n2)</p><p>function SelectionSort(v[1..n])</p><p>for i = 1 to n - 1 do</p><p>min = i</p><p>for j = i + 1 to n do</p><p>if v[j] &lt; v[min] then</p><p>min = j</p><p>end if</p><p>end for</p><p>if min != i then</p><p>temp = v[i]</p><p>v[i] = v[min]</p><p>v[min] = temp</p><p>end if</p><p>end for</p><p>end function</p><p>11</p><p> ( )</p><p>1 </p><p>2 ( worst case)</p><p>4 </p></li><li><p> (binary counter)</p><p>1212</p><p> L ( 2L )</p><p> Increment, </p><p> 0</p><p> 5 :</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 0 0 0 0</p></li><li><p> (binary counter)</p><p>1313</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 0 0 0 1</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 0 0 1 0</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 0 0 1 1</p><p>Increment: 1 2</p><p>Increment: 0 1</p><p>Increment: 2 3</p></li><li><p> (binary counter)</p><p>1414</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 0 1 0 0</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 0 1 0 1</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 0 1 1 0</p><p>Increment: 4 5</p><p>Increment: 3 4</p><p>Increment: 5 6</p></li><li><p> (binary counter)</p><p>15</p><p>function Increment(A)</p><p>i = 0</p><p>while i &lt; L and A[i] = 1 do</p><p>A[i] = 0</p><p>i = i + 1</p><p>end while</p><p>if i &lt; L then</p><p>A[i] = 1</p><p>end if</p><p>end function</p><p>15</p><p> 3 2 1 0</p><p> 8 4 2 1</p><p> 1 0 1 1</p><p> ( </p><p>)</p><p>= 1110</p></li><li><p> (binary counter)</p><p>16</p><p>function Increment(A)</p><p>i = 0</p><p>while i &lt; L and A[i] = 1 do</p><p>A[i] = 0</p><p>i = i + 1</p><p>end while</p><p>if i &lt; L then</p><p>A[i] = 1</p><p>end if</p><p>end function</p><p>16</p><p> 3 2 1 0</p><p> 8 4 2 1</p><p> 1 0 1 1 = 1110</p><p> Increment </p><p> A[1..L]</p></li><li><p> (binary counter)</p><p>17</p><p>function Increment(A)</p><p>i = 0</p><p>while i &lt; L and A[i] = 1 do</p><p>A[i] = 0</p><p>i = i + 1</p><p>end while</p><p>if i &lt; L then</p><p>A[i] = 1</p><p>end if</p><p>end function</p><p>17</p><p> Increment </p><p> A[1..L]</p><p> Increment?</p></li><li><p> (binary counter)</p><p>18</p><p> A[1..L] , </p><p> Increment O(L)</p><p> !</p><p> Increment </p><p>18</p><p>, </p><p> ?</p></li><li><p>19</p><p> (amortized analysis) , n </p><p> n , </p><p>19</p></li><li><p>20</p><p> , </p><p> , </p><p> n </p><p>20</p></li><li><p>21</p><p> (aggregate analysis)</p><p> (Robert Tarjan) 1985 :</p><p>Tarjan R. Amortized Computational Complexity // SIAM. J. on Algebraic and Discrete Methods, 6(2), 1985. </p><p> P. 306318.</p><p>21</p></li><li><p>22</p><p> (aggregate analysis)</p><p> (accounting method)</p><p> (potential method)</p><p>, </p><p>[CLRS ed., . 487]</p><p>22</p></li><li><p> (ggregate analysis)</p><p>23</p><p> (aggregate analysis) , T(n) n </p><p> (amortized cost, ) </p><p>T(n) / n</p><p>23</p></li><li><p> (Last In First Out)</p><p>2424</p><p>Push(S, x)</p><p>x</p><p>TPush = O(1)</p><p>Pop(S)</p><p>TPop = O(1)</p><p>MultiPop(S, k)</p><p>TMultiPop = O(min(|S|, k))</p><p>k</p></li><li><p>function MultiPop(S, k)</p><p>while StackEmpty(S) = False and k &gt; 0 do</p><p>StackPop(S)</p><p>k = k 1</p><p>end while</p><p>end function</p><p> (Last In First Out)</p><p>25</p><p>TMultiPop = O(min(|S|, k))15</p><p>4</p><p>22</p><p>78</p><p>34</p><p>12</p><p>Top </p><p>34</p><p>12</p><p>Top </p><p> MultiPop(S, 4) MultiPop(S, 7) </p></li><li><p> v1.0</p><p>26</p><p> T(n) n (Push, Pop, MultiPop)</p><p>1. Pop O(1)</p><p>2. Push O(1)</p><p>3. MultiPop O(n), n n </p><p> n MultiPop</p><p> , T(n) n O(n2), </p><p>O(n2) / n = O(n)</p><p>26 </p></li><li><p> v2.0</p><p>27</p><p> T(n) n </p><p>1. Pop ( MultiPop) Push. , Push n ( MultiPop Pop)</p><p>2. n Push, Pop, MultiPop O(n)</p><p> n O(n), ( ) </p><p>O(n) / n = O(1)27</p></li><li><p> : </p><p>28</p><p> , (1), MultiPush(S, k), k ?</p><p>28</p><p>MultiPush(S, k)</p><p>k</p><p>TMultiPush = O(k)</p></li><li><p> : </p><p>29</p><p> O(k)</p><p> n </p><p> n </p><p>MultiPush, O(nk)</p><p>( ) </p><p> T(n) / n = O(nk) / n = O(k) 29</p><p>MultiPush(S, k)</p><p>k</p></li><li><p> (binary counter)</p><p>3030</p><p> L ( 2L )</p><p> Increment</p><p> 5 </p><p>o 1, : 00001</p><p>o 3, : 00011</p><p>o 4, : 00100</p><p>o 5, : 00101</p><p>o 10, : 01010</p><p> 4 3 2 1 0</p><p> 16 8 4 2 1</p><p> 0 1 1 0 0</p></li><li><p>function Increment(A)</p><p>i = 0</p><p>while i &lt; L and A[i] = 1 do</p><p>A[i] = 0</p><p>i = i + 1</p><p>end while</p><p>if i &lt; L then</p><p>A[i] = 1</p><p>end if</p><p>end function</p><p> (binary counter)</p><p>3131</p><p> Increment </p><p> A</p><p> 3 2 1 0</p><p> 8 4 2 1</p><p> 1 0 1 1</p></li><li><p> (binary counter)</p><p> (L = 8 )</p><p>. A[7] A[4] A[3] A[2] A[1] A[0] (# )</p><p>1 0</p><p>0 0 0 0 1 1 1</p><p>2 0 0 0 0 1 0 2 3</p><p>3 0 0 0 0 1 1 1 4</p><p>4 0 0 0 1 0 0 3 7</p><p>5 0 0 0 1 0 1 1 8</p><p>6 0 0 0 1 1 0 2 10</p><p>7 0 0 0 1 1 1 1 11</p><p>8 0 0 1 0 0 0 4 15</p><p>9 0 0 1 0 0 1 1 16</p><p>10 0 0 1 0 1 0 2 18</p><p>11 0 0 1 0 1 1 1 19</p><p>12 0 0 1 1 0 0 3 22</p><p>13 0 0 1 1 0 1 1 23</p><p>14 0 0 1 1 1 0 2 25</p><p>15 0 0 1 1 1 1 1 26</p><p>16 0 1 0 0 0 0 5 31</p></li><li><p> (binary counter)</p><p> (L = 8 )</p><p>. A[7] A[4] A[3] A[2] A[1] A[0] (# )</p><p>1 0</p><p>0 0 0 0 1 1 1</p><p>2 0 0 0 0 1 0 2 3</p><p>3 0 0 0 0 1 1 1 4</p><p>4 0 0 0 1 0 0 3 7</p><p>5 0 0 0 1 0 1 1 8</p><p>6 0 0 0 1 1 0 2 10</p><p>7 0 0 0 1 1 1 1 11</p><p>8 0 0 1 0 0 0 4 15</p><p>9 0 0 1 0 0 1 1 16</p><p>10 0 0 1 0 1 0 2 18</p><p>11 0 0 1 0 1 1 1 19</p><p>12 0 0 1 1 0 0 3 22</p><p>13 0 0 1 1 0 1 1 23</p><p>14 0 0 1 1 1 0 2 25</p><p>15 0 0 1 1 1 1 1 26</p><p>16 0 1 0 0 0 0 5 31</p><p> Increment ( )? </p></li><li><p> (binary counter)</p><p> (L = 8 )</p><p>. A[7] A[4] A[3] A[2] A[1] A[0] (# )</p><p>1 0</p><p>0 0 0 0 1 1 1</p><p>2 0 0 0 0 1 0 2 3</p><p>3 0 0 0 0 1 1 1 4</p><p>4 0 0 0 1 0 0 3 7</p><p>5 0 0 0 1 0 1 1 8</p><p>6 0 0 0 1 1 0 2 10</p><p>7 0 0 0 1 1 1 1 11</p><p>8 0 0 1 0 0 0 4 15</p><p>9 0 0 1 0 0 1 1 16</p><p>10 0 0 1 0 1 0 2 18</p><p>11 0 0 1 0 1 1 1 19</p><p>12 0 0 1 1 0 0 3 22</p><p>13 0 0 1 1 0 1 1 23</p><p>14 0 0 1 1 1 0 2 25</p><p>15 0 0 1 1 1 1 1 26</p><p>16 0 1 0 0 0 0 5 31</p><p> T(n) n Increment</p><p> Increment ( ) </p><p>T(n) / n</p></li><li><p> (binary counter)</p><p> (L = 8 )</p><p>. A[7] A[4] A[3] A[2] A[1] A[0] </p><p>1 0</p><p>0 0 0 0 1 1 1</p><p>2 0 0 0 0 1 0 2 3</p><p>3 0 0 0 0 1 1 1 4</p><p>4 0 0 0 1 0 0 3 7</p><p>5 0 0 0 1 0 1 1 8</p><p>6 0 0 0 1 1 0 2 10</p><p>7 0 0 0 1 1 1 1 11</p><p>8 0 0 1 0 0 0 4 15</p><p>9 0 0 1 0 0 1 1 16</p><p>10 0 0 1 0 1 0 2 18</p><p>11 0 0 1 0 1 1 1 19</p><p>12 0 0 1 1 0 0 3 22</p><p>13 0 0 1 1 0 1 1 23</p><p>14 0 0 1 1 1 0 2 25</p><p>15 0 0 1 1 1 1 1 26</p><p>16 0 1 0 0 0 0 5 31</p><p> , </p><p> n </p><p>2n T(n)n T(n)</p></li><li><p> (binary counter)</p><p> (L = 8 )</p><p>. A[7] A[4] A[3] A[2] A[1] A[0] </p><p>1 0</p><p>0 0 0 0 1 1 1</p><p>2 0 0 0 0 1 0 2 3</p><p>3 0 0 0 0 1 1 1 4</p><p>4 0 0 0 1 0 0 3 7</p><p>5 0 0 0 1 0 1 1 8</p><p>6 0 0 0 1 1 0 2 10</p><p>7 0 0 0 1 1 1 1 11</p><p>8 0 0 1 0 0 0 4 15</p><p>9 0 0 1 0 0 1 1 16</p><p>10 0 0 1 0 1 0 2 18</p><p>11 0 0 1 0 1 1 1 19</p><p>12 0 0 1 1 0 0 3 22</p><p>13 0 0 1 1 0 1 1 23</p><p>14 0 0 1 1 1 0 2 25</p><p>15 0 0 1 1 1 1 1 26</p><p>16 0 1 0 0 0 0 5 31</p><p> 0 n ( Increment)</p><p> 1: /2 </p><p> 2: /4 </p><p> L-1 /21 </p><p> = +</p><p>2+</p><p>4++</p><p>21=</p><p>= + = 2</p></li><li><p> (binary counter)</p><p> (L = 8 )</p><p>. A[7] A[4] A[3] A[2] A[1] A[0] </p><p>1 0</p><p>0 0 0 0 1 1 1</p><p>2 0 0 0 0 1 0 2 3</p><p>3 0 0 0 0 1 1 1 4</p><p>4 0 0 0 1 0 0 3 7</p><p>5 0 0 0 1 0 1 1 8</p><p>6 0 0 0 1 1 0 2 10</p><p>7 0 0 0 1 1 1 1 11</p><p>8 0 0 1 0 0 0 4 15</p><p>9 0 0 1 0 0 1 1 16</p><p>10 0 0 1 0 1 0 2 18</p><p>11 0 0 1 0 1 1 1 19</p><p>12 0 0 1 1 0 0 3 22</p><p>13 0 0 1 1 0 1 1 23</p><p>14 0 0 1 1 1 0 2 25</p><p>15 0 0 1 1 1 1 1 26</p><p>16 0 1 0 0 0 0 5 31</p><p> () </p><p> Increment</p><p>O(n) / n = O(1) </p></li><li><p> (dynamic tables)</p><p>3838</p><p> (Dynamic table, dynamic array, </p><p>growable array) </p><p>o Insert(T, x)</p><p>o Delete(T, x)</p><p>o Size </p><p>o k </p><p>Size</p><p>k</p></li><li><p> (dynamic tables)</p><p>39</p><p> Insert </p><p> ?</p><p> k ( )</p><p> k ( )</p><p> :</p><p>o ++: std::vector</p><p>o Java: ArrayList</p><p>o .NET 2.0: List</p><p>o Python: list</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p>x1</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p>x1</p><p>x2</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p>x1</p><p>x2</p><p>x3</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p>x1</p><p>x2</p><p>x3</p><p>x4</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p>x1</p><p>x2</p><p>x3</p><p>x5</p><p>x4</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p>x1</p><p>x2</p><p>x3</p><p>x6</p><p>x5</p><p>x4</p></li><li><p> (dynamic tables)</p><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p>x1</p><p>x2</p><p>x3</p><p>x7</p><p>x6</p><p>x5</p><p>x4</p></li><li><p> (dynamic tables)</p><p>4848</p><p> T(n) </p><p> n Insert</p><p> Insert </p><p> : k</p><p> Size</p><p>Table[k] = x</p><p>Size</p><p>k</p></li><li><p>function Insert(x)if Size = 0 then</p><p>Size = 1Table = AllocateMemory(1)k = 0</p><p>else if k = Size thenSize = Size * 2NewTable = AllocateMemory(Size)for i = 0 to k 1 do</p><p>NewTable[i] = Table[i]end forFreeMemory(Table)Table = NewTable</p><p>end if Table[k] = xk = k + 1</p><p>end function</p><p> Insert</p><p> Insert 1 </p><p> 2 . (Copy 1 + Write 1)</p><p> 3 . (Copy 2 + Write 1)</p><p> 1 .</p><p> 5 . (Copy 4 + Write 1)</p></li><li><p> Insert</p><p>5050</p><p> ci , </p><p> i- Insert</p><p> = , 1 2,1, .</p><p> T(n) </p><p>n Insert </p><p> = 1 + 2 ++ + 20 + 21 + 22 ++ 2 log2 </p><p>() &lt; + 2 = 3</p></li><li><p>5151</p><p> Insert </p><p> = </p><p>=</p><p>3</p><p>= 3 = ()</p><p> ( ) </p><p> Insert O(1)</p><p> Insert</p></li><li><p>function AddToBuffer(value)Count = Count + 1Buffer[Count] = valueif Count = H then</p><p>for i = 1 to H doPacket[i] = Buffer[i]</p><p>end forCount = 0</p><p>end if end function</p><p>5252</p></li><li><p>5353</p><p> T(n) </p><p> n AddToBuffer</p><p> AddToBuffer</p></li><li><p> AddToBuffer</p><p>5454</p><p> ci , </p><p> i- AddToBuffer</p><p> = + 3, % = 0,</p><p>2, .</p><p> T(n) n </p><p> AddToBuffer </p><p> = 1 + 2 ++ &lt; 2 + 3 + </p><p>&lt; 2 + 3 + </p><p>= 5 + </p><p> = 5 + = ( + )</p></li><li><p> AddToBuffer</p><p>5555</p><p> T(n) n </p><p>AddToBuffer</p><p> = 5 + = + </p><p> () </p><p> AddToBuffer</p><p>=</p><p>5 +</p><p>= 1</p></li><li><p>56</p><p> [CLRS 3ed., . 487]:</p><p>o 17.2 </p><p>o 17.3 </p><p> .., .., .., . : . </p><p> 3- . .: , 2013. 1328 .</p></li></ul>

Recommended

View more >