Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color 5.45, 5.46 #1241

Merged
merged 2 commits into from Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions resources/lang/en/exercises/5_45.php
Expand Up @@ -9,19 +9,31 @@
'2' =>
"a. Exercise ",
'3' =>
" asked you to determine, as a function of n, the number of pushes and the maximum stack depth needed by the evaluator to compute n! using the recursive factorial procedure given above. Exercise ",
" asked you to determine, as a function of n",
'4' =>
" asked you to do the same measurements for the special-purpose factorial machine shown in figure 5.11. Now perform the same analysis using the compiled factorial procedure.",
", the number of pushes and the maximum stack depth needed by the evaluator to compute n!",
'5' =>
" using the recursive factorial procedure given above. Exercise ",
'6' =>
" asked you to do the same measurements for the special-purpose factorial machine shown in figure 5.11. Now perform the same analysis using the compiled factorial",
'7' =>
" procedure.",
'8' =>
"Take the ratio of the number of pushes in the compiled version to the number of pushes in the interpreted version, and do the same for the maximum stack depth. " .
"Since the number of operations and the stack depth used to compute n! are linear in n, these ratios should approach constants as n becomes large. " .
"Since the number of operations and the stack depth used to compute n!",
'9' =>
" are linear in n",
'10' =>
", these ratios should approach constants as n",
'11' =>
" becomes large. " .
"What are these constants? Similarly, find the ratios of the stack usage in the special-purpose machine to the usage in the interpreted version.",
'6' =>
'12' =>
"Compare the ratios for special-purpose versus interpreted code to the ratios for compiled versus interpreted code. " .
"You should find that the special-purpose machine does much better than the compiled code, since the hand-tailored controller code should be much better than what is produced by our rudimentary general-purpose compiler.",
'7' =>
'13' =>
"b. Can you suggest improvements to the compiler that would help it generate code that would come closer in performance to the hand-tailored version?",
'8' =>
'14' =>
"Figure 5.11: A recursive factorial machine.",
],
];
6 changes: 5 additions & 1 deletion resources/lang/en/exercises/5_46.php
Expand Up @@ -10,8 +10,12 @@
'3' =>
"compared to the effectiveness of using the special-purpose Fibonacci machine of figure 5.12. (For measurement of the interpreted performance, see exercise ",
'4' =>
".) For Fibonacci, the time resource used is not linear in n; hence the ratios of stack operations will not approach a limiting value that is independent of n.",
".) For Fibonacci, the time resource used is not linear in ",
'5' =>
"; hence the ratios of stack operations will not approach a limiting value that is independent of ",
'6' =>
".",
'7' =>
"Figure 5.12: Controller for a machine to compute Fibonacci numbers.",
],
];
25 changes: 18 additions & 7 deletions resources/lang/ru/exercises/5_45.php
Expand Up @@ -9,19 +9,30 @@
'2' =>
"а. В упражнении ",
'3' =>
" от Вас требовалось определить как функцию от n число сохранений и максимальную глубину стека, которые требуются вычислителю для того, чтобы получить n! с помощью указанной факториальной процедуры. В упражнении ",
" от Вас требовалось определить как функцию от ",
'4' =>
"Вас просили провести те же измерения для специализированной факториальной машины, показанной на рисунке 5.11. Проведите теперь тот же анализ для скомпилированной процедуры factorial.",
" число сохранений и максимальную глубину стека, которые требуются вычислителю для того, чтобы получить ",
'5' =>
"Возьмем отношение числа сохранений в скомпилированной версии к числу сохранений в интерпретируемой версии и проделаем то же для максимальной глубины стека. " .
"Поскольку число операций и глубина стека при вычислении n! линейно зависят от n, эти отношения должны приближаться к константам при росте n. " .
"Чему равны эти константы? Найдите также отношения показателей использования стека в специализированной машине к показателям интерпретируемой версии.",
" с помощью указанной факториальной процедуры. В упражнении ",
'6' =>
"Вас просили провести те же измерения для специализированной факториальной машины, показанной на рисунке 5.11. Проведите теперь тот же анализ для скомпилированной процедуры ",
'7' =>
".",
'8' =>
"Возьмем отношение числа сохранений в скомпилированной версии к числу сохранений в интерпретируемой версии и проделаем то же для максимальной глубины стека. " .
"Поскольку число операций и глубина стека при вычислении ",
'9' =>
" линейно зависят от ",
'10' =>
", эти отношения должны приближаться к константам при росте ",
'11' =>
". Чему равны эти константы? Найдите также отношения показателей использования стека в специализированной машине к показателям интерпретируемой версии.",
'12' =>
"Сравните отношения специализированной версии к интерпретируемой и отношения скомпилированной версии к интерпретируемой. " .
"Вы должны увидеть, что специализированная машина работает намного лучше скомпилированного кода, поскольку настроенный вручную код контроллера должен быть намного лучше, чем результаты работы нашего рудиментарного компилятора общего назначения.",
'7' =>
'13' =>
"б. Можете ли Вы предложить изменения в компиляторе, помогающие ему порождать код, который приблизится к показателям версии, построенной вручную?",
'8' =>
'14' =>
"Рис. 5.11. Рекурсивная факториальная машина.",
],
];
6 changes: 5 additions & 1 deletion resources/lang/ru/exercises/5_46.php
Expand Up @@ -10,8 +10,12 @@
'3' =>
"по сравнению с эффективностью работы специализированной машины Фибоначчи с рисунка 5.12. (Измерения интерпретируемой версии см. в упражнении ",
'4' =>
".) Для процедуры Фибоначчи время растет в нелинейной зависимости от n; следовательно, отношение числа стековых операций не будет приближаться к независимому от n пределу.",
".) Для процедуры Фибоначчи время растет в нелинейной зависимости от ",
'5' =>
"; следовательно, отношение числа стековых операций не будет приближаться к независимому от ",
'6' =>
" пределу.",
'7' =>
"Рис. 5.12. Контроллер машины для вычисления чисел Фибоначчи.",
],
];
27 changes: 21 additions & 6 deletions resources/views/exercise/listing/5_45.blade.php
@@ -1,10 +1,25 @@
<p>{{ __('exercises/5_45.description.1') }}</p>
<p>{{ __('exercises/5_45.description.2') }}<a href="{{ route('exercises.show', getExercise('5.27')) }}">5.27</a>
{{ __('exercises/5_45.description.3') }}<a href="{{ route('exercises.show', getExercise('5.14')) }}">5.14</a>
{{ __('exercises/5_45.description.4') }}</p>
<p>{{ __('exercises/5_45.description.5') }}</p>
<p>{{ __('exercises/5_45.description.6') }}</p>
<p>{{ __('exercises/5_45.description.7') }}</p>
{{ __('exercises/5_45.description.3') }}
<code>n</code>
{{ __('exercises/5_45.description.4') }}
<code>n!</code>
{{ __('exercises/5_45.description.5') }}
<a href="{{ route('exercises.show', getExercise('5.14')) }}">5.14</a>
{{ __('exercises/5_45.description.6') }}
<code>factorial</code>
{{ __('exercises/5_45.description.7') }}
</p>
<p>{{ __('exercises/5_45.description.8') }}
<code>n!</code>
{{ __('exercises/5_45.description.9') }}
<code>n</code>
{{ __('exercises/5_45.description.10') }}
<code>n</code>
{{ __('exercises/5_45.description.11') }}
</p>
<p>{{ __('exercises/5_45.description.12') }}</p>
<p>{{ __('exercises/5_45.description.13') }}</p>
<img class="img-fluid" src="{{ mix('img/exercises/5_12.gif') }}" alt="5.12">
<pre><code>(controller
(assign continue (label fact-done)) ; set up final return address
Expand All @@ -29,4 +44,4 @@
(goto (reg continue)) ; return to caller
fact-done)
</code></pre>
<p>{{ __('exercises/5_45.description.8') }}</p>
<p>{{ __('exercises/5_45.description.14') }}</p>
9 changes: 7 additions & 2 deletions resources/views/exercise/listing/5_46.blade.php
Expand Up @@ -6,7 +6,12 @@
(+ (fib (- n 1)) (fib (- n 2)))))
</code></pre>
<p>{{ __('exercises/5_46.description.3') }}<a href="{{ route('exercises.show', getExercise('5.29')) }}">5.29</a>
{{ __('exercises/5_46.description.4') }}</p>
{{ __('exercises/5_46.description.4') }}
<code>n</code>
{{ __('exercises/5_46.description.5') }}
<code>n</code>
{{ __('exercises/5_46.description.6') }}
</p>
<pre><code>(controller
(assign continue (label fib-done))
fib-loop
Expand Down Expand Up @@ -39,4 +44,4 @@
(goto (reg continue))
fib-done)
</code></pre>
{{ __('exercises/5_46.description.5') }}</p>
{{ __('exercises/5_46.description.7') }}</p>