Skip to content

Commit

Permalink
Added links to the exercise in ch12
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxinyu95 committed Apr 23, 2023
1 parent 424db76 commit 2151504
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion datastruct/elementary/sequence/sequence-en.tex
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ \section{Concatenate-able list}
concat = fold\ (\doubleplus)\ \nil
\ee

The performance is bound to linear time in worst case: delete after repeatedly add $n$ elements. All $n-1$ sub-trees are singleton. $concat$ takes $O(n)$ time to consolidate. The amortized performance is constant time if add, append, delete randomly happen.
Normally, the add, append, delete randomly happen. The performance is bound to linear time in worst case: delete after repeatedly add $n$ elements. All $n-1$ sub-trees are singleton. $concat$ takes $O(n)$ time to consolidate. Nevertheless, the amortized performance is constant time.

\begin{Exercise}
\Question{Prove the amortized performance for delete is constant time} %Banker method.
Expand Down
26 changes: 16 additions & 10 deletions datastruct/elementary/sequence/sequence-zh-cn.tex
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,17 @@ \section{可连接列表}
concat = fold\ (\doubleplus)\ \nil
\ee

删除操作的性能在最坏情况下是线性的。当连续向空序列添加$n$个元素后,立即执行一次删除。此时多叉树中的$n-1$棵子树都是单元素的(只含有一个叶子节点)。$concat$需要$O(n)$时间进行归并。如果插入、添加、删除、连接随机发生,则分摊复杂度是常数时间的
通常情况下插入、添加、删除、连接随机发生。删除操作的性能在最坏情况下是线性的。当连续向空序列添加$n$个元素后,立即执行一次删除。此时多叉树中的$n-1$棵子树都是单元素的(只含有一个叶子节点)。$concat$需要$O(n)$时间进行归并。但其分摊复杂度是常数时间的

\begin{Exercise}
\Question{证明可连接列表的删除操作的分摊复杂度为常数时间的。} %Banker方法
\end{Exercise}
%% \begin{Exercise}\label{ex:clist-seq}
%% 分析可连接列表的删除操作的分摊复杂度。
%% \end{Exercise}

%% \begin{Answer}[ref = {ex:clist-seq}]
%% 分析可连接列表的删除操作的分摊复杂度。

%% % Banker's method, Purely Function Data Structure, pp 156 - 158
%% \end{Answer}

\section{手指树}
\index{序列!手指树}
Expand Down Expand Up @@ -592,11 +598,11 @@ \subsection{插入}
xs \gg t = foldr\ insert\ t\ xs
\ee

\begin{Exercise}
\begin{Exercise}\label{ex:finger-tree-insert}
\Question{消除递归,用循环的方式实现手指树插入。}
\end{Exercise}

\begin{Answer}
\begin{Answer}[ref = {ex:finger-tree-insert}]
\Question{消除递归,用循环的方式实现手指树插入。
对于手指树$T = (f, t, r)$,令$\textproc{Mid}(T) = t$以获取中间部分。

Expand Down Expand Up @@ -673,11 +679,11 @@ \subsection{删除}
\end{cases}
\ee

\begin{Exercise}
\begin{Exercise}\label{ex:finger-tree-del}
\Question{消除递归,用循环实现删除。}
\end{Exercise}

\begin{Answer}
\begin{Answer}[ref = {ex:finger-tree-del}]
\Question{消除递归,用循环实现删除。

如果删除后front手指变空,就从中间部分的子树中“借”节点。但是树的形式有可能是不规则的,例如front手指和中间子树都为空。这种情况通常是由于分拆操作造成的。
Expand Down Expand Up @@ -941,12 +947,12 @@ \subsection{随机访问}

在后面章节中,我们将介绍基本的分而治之的排序算法,包括快速排序、归并排序以及它们的变形;然后我们介绍字符串匹配算法和基本搜索算法。

\begin{Exercise}
\begin{Exercise}\label{ex:finger-tree-index}
\Question{在随机访问时,如何处理空树$\nil$和索引越界的情况?}
\Question{实现$cut\ i\ S$,在位置$i$把序列$S$分割开。}
\end{Exercise}

\begin{Answer}
\begin{Answer}[ref = {ex:finger-tree-index}]
\Question{在随机访问时,如何处理空树$\nil$和索引越界的情况?

我们可以在索引时进行越界检查,例如:
Expand Down

0 comments on commit 2151504

Please sign in to comment.