Skip to content

Commit

Permalink
Clean up a writing tic.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcmyers committed Nov 5, 2024
1 parent bb783fb commit 762222f
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 31 deletions.
6 changes: 3 additions & 3 deletions lectures/avl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ <h2>Deleting from an AVL tree</h2>

<h2>Random Treaps</h2>
<p>
There are several other ways to balance search trees. One good one is <b>random
Search trees can be balanced in several other ways. One good one is <b>random
treaps</b>, which are balanced with high probability. Balancing is achieved by
ensuring the tree has exactly the same structure that it would have had if the
elements had been inserted into a binary search tree in a random order.
Expand Down Expand Up @@ -726,8 +726,8 @@ <h2>Other balanced binary trees</h2>
<p>
Other balanced binary search trees (and more generally, n-ary search trees)
also strengthen the search tree invariant to ensure that the tree remains
balanced. There are many balanced search tree data structures; some of the
most important are:
balanced. Of the many balanced search tree data structures, here are some of the
most important:
<ul>
<li>Red–black trees
<ul>
Expand Down
4 changes: 2 additions & 2 deletions lectures/graphs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h2>Uses of graphs</h2>
trying to invent a new algorithm for the specific domain of interest.
</p>
<p>
There are many computational problems over graphs that are not known to
Many computational problems over graphs are not known to
be solvable in any reasonable amount of time. In particular, there is a large class of problems
known as the <strong>NP complete problems</strong> that are not known to be efficiently solvable, but
are known to be equivalent in complexity. If we could give an efficient algorithm for solving
Expand Down Expand Up @@ -189,7 +189,7 @@ <h2>Labels</h2>

<h2>Graph representations</h2>
<p>
There are several ways to represent graphs in a computer program. Which
Graphs can be represented in a computer program in several ways, and which
representation is best depends on the application.
For example, consider the following weighted directed graph with vertices {0,1,2,3}
and directed edges with edge weights shown:
Expand Down
6 changes: 3 additions & 3 deletions lectures/gui_swing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ <h2>Layout</h2>

<h2>Appearance</h2>

<p>There are several ways to control the appearance of the scene. Some components have handles that
allow them to be minimized, maximized, or resized. There are also various controls such as
sliders or knobs to control shape, size, color, or other aspect of the appearance. Components can also be
<p>The appearance of the scene can be controlled in many ways. Some components have handles that
allow them to be minimized, maximized, or resized. Various controls such as
sliders or knobs can control shape, size, color, or other aspects of the appearance. Components can also be
added, removed, moved, or transformed.
</p>

Expand Down
14 changes: 8 additions & 6 deletions lectures/hashtables/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ <h2>Step 2: Hashing</h2>
<h2>Step 3: Collision resolution</h2>
<h3>Chaining</h3>
<p>
There are two main ideas for how to deal with collisions. The best way is
Collisions are dealt with in two main ways. The best way is
usually <strong>chaining</strong>: each array entry corresponds to a <strong>bucket</strong>
containing a mutable set of elements. (Confusingly, this approach is sometimes called
<strong>closed addressing</strong> or <strong>open hashing</strong>.) Typically, the bucket is
Expand Down Expand Up @@ -525,9 +525,9 @@ <h2>Hash functions</h2>
influencing the choice of keys.
</p>
<p>
There are relatively inexpensive hash functions that work well for less
adversarial situations, and more expensive hash functions that make it
infeasible for an adversary to choose keys that collide. A key property we want
Some relatively cheap hash functions work well for less
adversarial situations, whereas more expensive hash functions must be used
to make it infeasible for an adversary to choose keys that collide. A key property we want
is <em>diffusion</em>: the hashes of two related keys should appear to have no
relation to each other. In particular, if any two keys \(k\) and \(k'\) are
“close” to each other in the sense that the computation is likely to generate
Expand Down Expand Up @@ -647,11 +647,13 @@ <h2>Hash tables in the Java Collection Framework</h2>
the internal hash function does not produce much diffusion, so it is important
for the client-provided <code>hashCode()</code> to do so.
</p>

<h2>Generating hash codes</h2>

<p>
A poorly designed <code>hashCode()</code> method can cause the hash table
implementation to fail to work correctly or to exhibit poor performance. There are
two main considerations:
implementation to fail to work correctly or to exhibit poor performance.
Two main considerations apply:
</p>
<ol>
<li><p>For the hash table to work, the <code>hashCode()</code> method must be
Expand Down
4 changes: 2 additions & 2 deletions lectures/heaps/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ <h1>Priority Queues and Heaps</h1>
We have already seen that priority queues are useful for implementing Dijkstra's algorithm
and A<sup>*</sup> search. In these applications, the priority is the best-known estimate of a
shortest distance. Such a queue is called a <b>min-queue</b> because the smaller the distance,
the higher the priority. There are also <b>max-queues</b> in which larger numbers correspond to
higher priorities, but they can be implemented in the same way.</p>
the higher the priority. <b>Max-queues</b> in which larger numbers correspond to
higher priorities can be implemented in essentially the same way.</p>

<p>
Another application in which priority queues are very useful is <em>discrete
Expand Down
4 changes: 2 additions & 2 deletions lectures/intf_design/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ <h2>Implementing equality</h2>
what equality means for the objects you are implementing. Equality is a deep
subject that mathematicians and computer scientists are still arguing about! As
software developers aiming for effective abstractions, we need to think about it
too. There are two natural ways to define equality on two values:
too. The equality of two values can be defined in two natural ways:
<ul>
<li><p><b>Leibniz equality.</b> The mathematician
<a href="https://en.wikipedia.org/wiki/Gottfried_Wilhelm_Leibniz">Leibniz</a>
Expand Down Expand Up @@ -668,7 +668,7 @@ <h2>Implementing equality</h2>
These implementation challenges reflect a problem in the specification of
<code>Object.equals()</code>. The expected mathematical properties of equality
are in tension with the approach of asking each object to be able to decide
whether it is equal to all other objects. There are approaches to equality that
whether it is equal to all other objects. Other approaches to equality
are more philosophically consistent, but since the Java libraries rely on the
<code>equals()</code> method in many places, we have to learn to live with
<code>equals()</code> and sometimes strike compromises.
Expand Down
4 changes: 2 additions & 2 deletions lectures/jvm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2>Interpreters vs. compilers</h2>
</p>
<h2>Interpreter designs</h2>
<p>
There are multiple kinds of software interpreters. The simplest
Software interpreters come in different flavors. The simplest
interpreters are abstract syntax tree (AST) interpreters, which
take as input the program represented as a tree. To get the program
into a tree representation, <a href="../../lecture.html?id=parsing">parsing</a> is required. AST
Expand Down Expand Up @@ -189,7 +189,7 @@ <h3>Method dispatch</h3>
from the method, if any, is pushed onto the operand stack of the
caller.
</p><p>
There are multiple bytecode instructions for calling methods. Given a
Multiple bytecode instructions exist for calling methods. Given a
call <code>x.eat(5)</code>, where <code>eat</code> is an ordinary non-final, non-private
method and <code>x</code> has static type <code>Animal</code>, the corresponding invocation
bytecode is something like this:
Expand Down
2 changes: 1 addition & 1 deletion lectures/objects/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ <h2>Statements vs. expressions</h2>
</p>
</div>
<p>
There are other styles that people might use to format this code. For example,
People might format this code according to other styles. For example,
some people put the opening brace <code>{</code> on a line by itself, so that
the two matching braces line up in the same column. Others indent the braces
themselves. Some people do not put a space after the keyword <code>if</code>,
Expand Down
10 changes: 5 additions & 5 deletions lectures/patterns/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ <h2>Visitor</h2>
The Visitor pattern is an important pattern that allows the traversal of a tree
data structure (such as an abstract syntax tree) to be factored out from the
nodes of the tree in a generic way that can be reused for multiple traversals.
There are many variations on the visitor pattern.
The Visitor pattern has many variations.
</p>
<p>
Generally when building programs that manipulate abstract syntax tree, such as
Expand Down Expand Up @@ -569,7 +569,7 @@ <h2>Visitor</h2>
-->
<p>
The Visitor pattern provides a structure to help manage this tension.
There are a number of variation on the Visitor pattern, but the common
Among the variations on the Visitor pattern, the common
idea is that operations are expressed as subclasses of a common Visitor
class. In the classic Visitor pattern, the Visitor class (and its subclasses)
have one method for each possible type. The base Visitor class supplies
Expand Down Expand Up @@ -743,16 +743,16 @@ <h2>Model-View-Controller</h2>
simulation. The model will run on a shared server with one or more clients
viewing that model through a user interface.
</p>
<p>There are many variations of the MVC pattern. Some versions of the MVC
pattern make less of a distinction between the view and the controller; this
<p>The MVC pattern has many variations. Some versions
make less of a distinction between the view and the controller; this
is usually indicated by talking about the M/VC pattern, in which the view and the
controller are more tightly coupled, but strong separation is maintained between
the model and these two parts of the design.
</p>

<h2>Antipatterns</h2>
<p>
There are also coding patterns that are used frequently, but are best avoided. These
Coding patterns exist that are used frequently, yet are best avoided. These
are often dubbed &ldquo;antipatterns&rdquo;. For example, some Java programmers make heavy use
of reflection in Java. Using reflection is generally bad practice, leading to slow, fragile
code. A <em>good</em> reason to use reflection is if you are loading code dynamically
Expand Down
2 changes: 1 addition & 1 deletion lectures/radix_sort/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1>Linear-Time Sorting Algorithms</h1>
<p>
In recitation this week, you learned about a number of sorting algorithms, including
We have seen a number of sorting algorithms, including
<b>insertion sort</b> and <b>selection sort</b>, which are quadratic time in the worst case,
as well as <b>mergesort</b>, which is O(n log n) time in the worst case. You also learned about
<b>quicksort</b>, which is quadratic time in the worst case but O(n log n) expected time
Expand Down
2 changes: 1 addition & 1 deletion lectures/subtyping/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h3>Smoe implementations</h3>
</pre>

<p>
There are few interesting aspects of this code. First, notice that each method
This code has a few notable aspects. First, notice that each method
declared in the interface must be implemented as a <code>public</code> method
in the class. The class has some other components as well. For example, the
instance variables <code>tiles</code> and <code>score</code> are declared
Expand Down
6 changes: 3 additions & 3 deletions lectures/trees/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ <h1>Trees</h1>
creates additional maintenance requirements.
</p>
<h2>Why trees?</h2>
<p>There are two main reasons why tree data structures are important:</p>
<p>Tree data structures are important for two main reasons:</p>
<ol>
<li><p>Some information has a natural tree-like structure, so storing it
in trees makes sense. Examples of such information include parse trees of expressions,
Expand Down Expand Up @@ -440,7 +440,7 @@ <h3>Removing elements from a binary search tree</h3>
Removing elements from a tree is generally more complicated than adding them, because the
elements to be removed are not necessarily leaves. The algorithm starts by first finding the
node containing the value \(x\) to be removed and its parent node \(p\) (if any).
There are three cases to consider:
Three cases must be considered:
</p>
<ol>
<li><em>Node \(x\) is a leaf.</em>
Expand Down Expand Up @@ -687,7 +687,7 @@ <h3>Toward balanced trees</h3>
are balanced?
</p>
<p>
There are algorithms for efficiently rebalancing trees, relying on adding
Algorithms exist for efficiently rebalancing trees, relying on adding
additional bookkeeping information to the tree data structure. For example,
AVL trees and Red–Black trees are two commonly used augmented versions of
binary search trees, with accompanying algorithms for rebalancing them.
Expand Down

0 comments on commit 762222f

Please sign in to comment.