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

fixed types, cpp program errors #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpp/ArrayQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ ArrayQueue<T>::ArrayQueue() : a(1) {

template<class T>
ArrayQueue<T>::~ArrayQueue() {
delete a;
}

template<class T>
Expand Down
1 change: 1 addition & 0 deletions cpp/BinarySearchTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ bool BinarySearchTree<Node, T>::addChild(Node *p, Node *u) {
} else if (comp > 0) {
p->right = u;
} else {
delete u;
return false; // u.x is already in the tree
}
u->parent = p;
Expand Down
2 changes: 1 addition & 1 deletion cpp/BinaryTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void BinaryTree<Node>::bfTraverse() {
ArrayDeque<Node*> q;
if (r != nil) q.add(q.size(),r);
while (q.size() > 0) {
Node *u = q.remove(q.size()-1);
Node *u = q.remove(0);
if (u->left != nil) q.add(q.size(),u->left);
if (u->right != nil) q.add(q.size(),u->right);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/SLList.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SLList {
T x;
Node *next;
Node(T x0) {
x = 0;
x = x0;
next = NULL;
}
};
Expand Down
2 changes: 1 addition & 1 deletion latex/arrays.tex
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ \subsection{Summary}
calls to #resize()#, an #ArrayQueue# supports the operations
#add(x)# and #remove()# in $O(1)$ time per operation.
Furthermore, beginning with an empty #ArrayQueue#, any sequence of $m$
#add(i,x)# and #remove(i)# operations results in a total of $O(m)$
#add(x)# and #remove()# operations results in a total of $O(m)$
time spent during all calls to #resize()#.
\end{thm}

Expand Down
2 changes: 1 addition & 1 deletion latex/hashing.tex
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ \subsection{Hash Codes for Arrays and Strings}
$#y#_0,\ldots,#y#_{r'-1}$ be distinct sequences of #w#-bit integers in
$\{0,\ldots,2^{#w#}-1\}$. Then
\[
\Pr\{ h(#x#_0,\ldots,#x#_{r-1}) = h(#y#_0,\ldots,#y#_{r-1}) \}
\Pr\{ h(#x#_0,\ldots,#x#_{r-1}) = h(#y#_0,\ldots,#y#_{r'-1}) \}
\le \max\{r,r'\}/#p# \enspace .
\]
\end{thm}
Expand Down
2 changes: 1 addition & 1 deletion latex/intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ \subsection{Asymptotic Notation}
A number of useful shortcuts can be applied when using asymptotic
notation. First:
\[ O(n^{c_1}) \subset O(n^{c_2}) \enspace ,\]
for any $c_1 < c_2$. Second: For any constants $a,b,c > 0$,
for any $c_1 < c_2$. Second: For any constants $a,b > 0, c > 1$,
\[ O(a) \subset O(\log n) \subset O(n^{b}) \subset O({c}^n) \enspace . \]
These inclusion relations can be multiplied by any positive value,
and they still hold. For example, multiplying by $n$ yields:
Expand Down
4 changes: 2 additions & 2 deletions latex/redblack.tex
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ \subsection{Addition}
satisfies the left-leaning property. In this case we can stop.
\codeimport{ods/RedBlackTree.addFixup(u)}

The #insertFixup(u)# method takes constant time per iteration and each
The #addFixup(u)# method takes constant time per iteration and each
iteration either finishes or moves #u# closer to the root. Therefore,
the #insertFixup(u)# method finishes after $O(\log #n#)$ iterations in
the #addFixup(u)# method finishes after $O(\log #n#)$ iterations in
$O(\log #n#)$ time.

\subsection{Removal}
Expand Down