Skip to content

Commit 4550459

Browse files
Merge pull request #59 from 0xadb/typos
Removed typos and duplicates
2 parents 1b1710a + 386ebf2 commit 4550459

17 files changed

+59
-59
lines changed

01_data_structures.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Whomever really wants to learn, will learn, and that is a challenge because it i
135135
a room of programmers know it's going to be an empty set.
136136
That doesn't mean that you as an individual person doesn't know things, but intersection is going to be relatively small.
137137

138-
Unfortunatly we've got to a point where nobody teaches programming.
138+
Unfortunately we've got to a point where nobody teaches programming.
139139
Because there's no professor of computer science who has any idea how to program[^teaching-programming].
140140
Part of what I am trying to do here is to start discussing
141141
little things like, how do we name variables?
@@ -159,7 +159,7 @@ C++ treats `main` as a special function; meaning when the control goes
159159
through the last brace, zero is returned.
160160
Because the standard UNIX convention, which became Universal
161161
convention, that on success you return zero.
162-
The language actually allows you to do things things like that.
162+
The language actually allows you to do things like that.
163163

164164
One warning, [`cout`][cout] stuff works pretty much like how you think it works.
165165
However a friend of mine wrote something like:
@@ -209,7 +209,7 @@ When we narrowed things down we always found something
209209
pertaining to incorrect use of STL[^about-stl].
210210
It's usually a one liner and the most egregious.
211211

212-
The most most amazing thing is the following one liner which I will start in the
212+
The most amazing thing is the following one liner which I will start in the
213213
beginning of the course, because it was just so important.
214214
We could weave the whole fabric of the course around this one little example.
215215
There was a range of integers. For example:
@@ -251,7 +251,7 @@ Equality gives us linear search while sorting gives us binary search so we can f
251251
One of the amazing things which we will discover is that ordering is very important.
252252
Things which we could do with ordering cannot be effectively done just with equality[^cl-mistake].
253253

254-
If we are going by the book we we will say sorting is good as long it does approximately `O(n log(n))` operations.
254+
If we are going by the book we will say sorting is good as long it does approximately `O(n log(n))` operations.
255255
This is good for the books.
256256
It's actually not good for our code, because Big O
257257
could have an arbitrary coefficient.
@@ -464,7 +464,7 @@ specific type.
464464
This is very good, we have to have that.
465465
But then we also need to have times for specific commonly used types.
466466
So these are two things which we need to do.
467-
Our goal is to to be able to measure this problem with `set` and with sort.
467+
Our goal is to be able to measure this problem with `set` and with sort.
468468
But, first we need to learn more about C++.
469469

470470
[red-black]: https://en.wikipedia.org/wiki/Red%E2%80%93black_tree

02_regular_types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ So, I'm not even going to mention Yahoo (joke).
2626
I did interview at Facebook and let me tell you what I saw of that place...
2727
That was five years ago.
2828
Maybe they improved but I don't think so.
29-
Places tend to to decline.
29+
Places tend to decline.
3030

3131
You might say: "Who are you to tell us?"
3232
I am as guilty as any of you.
@@ -261,7 +261,7 @@ to `TotallyOrdered`.
261261

262262
**Axiom 3:** Anti-symmetric: If `a < b` then `!(b < a)`.
263263

264-
**Axiom 4:** If `a != b` then `a < b` or ` b > a`.
264+
**Axiom 4:** If `a != b` then `a < b` or `b > a`.
265265

266266
In the same way that the semantics of `==` is related to `!=`,
267267
we can see the semantics of `<` must be totally bound to the semantics of equality.

03_singleton.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ people think invented C++ are idealized in books like "Effective C++",
264264
He tells you always declare destructor as virtual[^scott-virtual].
265265
OK, he's wrong. Simple as that.
266266

267-
What we do we want to create? Take type `T`, put it in a struct. Will the size of the thing increase?
267+
What do we want to create? Take type `T`, put it in a struct. Will the size of the thing increase?
268268
No. It has no overhead.
269269
Singleton is the same size as `T`.
270270
It's the wonderful thing about singleton, and lets you pack them in arrays.
@@ -395,7 +395,7 @@ They were not copyable and you couldn't pass them as arguments.
395395
Then they fixed it.
396396
They said, "we'll just copy the bits" and things would work.
397397

398-
Equality is defined for all built-in types; `int`, `double`, `short`, `char`, pointers, etc.
398+
Equality is defined for all built-in types: `int`, `double`, `short`, `char`, pointers, etc.
399399
So, if you have a struct, why can't you generate an equality that uses those?
400400
Two things are equal if all their members are equal.
401401
It's a sensible rule a compiler could do.

04_instrumented.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Everything has its place, Dijkstra's strictures not withstanding[^goto].
324324

325325

326326
[^goto]: Goto used to be the primary way to do control flow in programs,
327-
because it closely resembles how how machines and their languages work.
327+
because it closely resembles how machines and their languages work.
328328

329329
For example, to implement a `while` loop, you might write:
330330

05_swap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ programs are:
120120

121121
1. `swap`: takes two things and swaps them.
122122
2. `min`: takes two things and figure out which one is smaller.
123-
2. `linear search`: goes through a bunch of stuff and finds the one you want.
123+
3. `linear search`: goes through a bunch of stuff and finds the one you want.
124124

125125
Aren't these too simple?
126126
If we cannot do simple things, it is very unlikely we will be able to do hard things.
@@ -133,7 +133,7 @@ I claim exciting things tend to be very simple and basic.
133133
So you say, "Alex, why don't we use a new language?"
134134
Go try implementing these three program in your favorite language.
135135
Do them in a general way.
136-
If they're at least relatively efficient, that is, they are not slower than specific things written in the language, then let us talk.
136+
If they're at least relatively efficient, that is, they are not slower than specific things written in the language, then let us talk.
137137
If you cannot do it, let us stick with C++.
138138
I'm just explaining the reasoning behind my choice of C++.
139139

@@ -182,7 +182,7 @@ You deny the utility of swap.
182182
A **group** is a set `G` with a binary operation `* : G x G -> G` such that:
183183

184184
1. `G` contains an identity element `e` in `G` such that `e * x = x * e = x` for all `x` in `G`.
185-
2. The operation `*` is associative. So `((x * y) * z) = (x * (y * z))` for all `x, y, z` in `G`.
185+
2. The operation `*` is associative. So `((x * y) * z) = (x * (y * z))` for all `x, y, z` in `G`.
186186
3. Every element `x` in `G` has an inverse element `y` such that x * y = y * x = e.
187187

188188
For example integers are a group with the operation of addition and the identity element 0.

06_min_max.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ It's guaranteed.
4848

4949
**Axiom 3:** Anti-symmetric: If `a < b` then `!(b < a)`.
5050

51-
**Axiom 4:** If `a != b` then `a < b` or ` b > a`.
51+
**Axiom 4:** If `a != b` then `a < b` or `b > a`.
5252

5353
This is also called the trichotomy law,
5454
because for all elements, exactly one of three things must be true[^eop-ordering]:
@@ -97,7 +97,7 @@ Because for `TotallyOrdered` we need to be able to know
9797

9898
The `==` is equality, not another equivalence relation.
9999
We can't conclude that with a weak ordering.
100-
We must overloaded symbols for what they commonly mean.
100+
We must overload symbols for what they commonly mean.
101101

102102
[^eop-ordering]: Alex recommends chapter 4 of "Elements of Programming"
103103
to learn more about this subject.
@@ -344,7 +344,7 @@ Every time I talk to one member of the standard
344344
committee he always says, "Alex you are too theoretical".
345345
I guess I am because I pay attention to
346346
these little details.
347-
But I claim to be able to to show you that
347+
But I claim to be able to show you that
348348
things like that will matter.
349349

350350
Later we will generalize it on a bunch of things.

07_min_range.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ So it must be a `ForwardIterator`.
186186

187187
## Finding min and max together
188188

189-
How many comparisons do we need to to find the min of five elements?
189+
How many comparisons do we need to find the min of five elements?
190190
Four.
191191
In general why do we need `n - 1` comparisons.
192192
Why no more? We don't need to compare an element with itself.

10_binary_counter.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ we're just rebalancing parentheses[^min-not-commutative].
230230
We distinguish between the left and right argument.
231231

232232
[^associativity]: A binary function `f` is [associative](https://en.wikipedia.org/wiki/Associative_property)
233-
if the the following holds for all `a, b, c` in its domain:
233+
if the following holds for all `a, b, c` in its domain:
234234

235235
f(f(a, b), c)) = f(a, f(b, c))
236236

@@ -265,7 +265,7 @@ we're just rebalancing parentheses[^min-not-commutative].
265265
* * * * * * * *
266266
* * *
267267

268-
Or as [Dirchlet][dirichlet] put it: "Whether you arrange soldiers in rows or columns, you still have the same number of soldiers".
268+
Or as [Dirichlet][dirichlet] put it: "Whether you arrange soldiers in rows or columns, you still have the same number of soldiers".
269269

270270
An example of an operation which is not commutative is string concatenation.
271271

@@ -281,7 +281,7 @@ They should have taught it in high school.
281281
But, they want to publish papers themselves and not tell you the general mechanism.
282282

283283
Let us assume we have elements of type `T` that need to be paired or combined in some way,
284-
whether with `min`, `+`, `merge`, or any other assocative operation on `T`.
284+
whether with `min`, `+`, `merge`, or any other associative operation on `T`.
285285
What we can do is create an array called a "counter".
286286

287287
index: 0 1 ... 31
@@ -323,12 +323,12 @@ Otherwise `x` wins:
323323

324324
What if the index `1` slot was non-zero, after comparing `x` and `y`?
325325
Then the guy there already won one game.
326-
So, we must **carry propogate**[^adder-circuit].
326+
So, we must **carry propagate**[^adder-circuit].
327327
Repeat the same process all the way up the counter, until we find a slot which is zero.
328328
What if the counter is full, and has no zero slots?
329329
That's called an **overflow**.
330330

331-
We borrow terminology from binary integer arithemtic because
331+
We borrow terminology from binary integer arithmetic because
332332
our counter works just like a binary integer counting up:
333333

334334
0 0 0
@@ -340,7 +340,7 @@ our counter works just like a binary integer counting up:
340340
0 1 1
341341
1 1 1
342342

343-
But instead of 0 and 1 in each slot or "bit" we have arbitary elements that are combined with an associative operation.
343+
But instead of 0 and 1 in each slot or "bit" we have arbitrary elements that are combined with an associative operation.
344344

345345
### Handling overflow
346346

@@ -363,7 +363,7 @@ on type `T` and what we discovered is if we have associativity,
363363
we can make this counter and it will work for us.
364364

365365
[^adder-circuit]: The terms **carry** and **overflow**
366-
are closely associated the implementation of binary counting
366+
are closely associated with the implementation of binary counting
367367
or addition as an electrical circuit, called an [adder][adder].
368368

369369
A single bit adder has two inputs `a` and `b` for
@@ -383,7 +383,7 @@ we can make this counter and it will work for us.
383383
1 1 | 1 0
384384

385385
This adds a single digit, but we want to add entire numbers.
386-
To, do so we add an additional input `l` for carried digits
386+
To do so we add an additional input `l` for carried digits
387387
from lower place values.
388388

389389
a b l c s
@@ -405,7 +405,7 @@ we can make this counter and it will work for us.
405405

406406
An **overflow** is when the last adder has a non-zero carry.
407407

408-
[^errors]: Floating point arithemetic can involve many tricky details,
408+
[^errors]: Floating point arithmetic can involve many tricky details,
409409
but the basic issue Alex is referring to is straightforward.
410410
We often use scientific notation to write larger numbers as a decimal to a power,
411411
when they would otherwise be very long to write out.
@@ -573,8 +573,8 @@ We could compete with Steve Jobs for elegance of our design[^alex-apple-joke].
573573

574574
**Exercise:** Rewrite `min_element` using this code (just `min_element`, don't worry about second best).
575575

576-
**Exercise:** If you want to implement [merge sort][merge-sort] you can use exactly the same device, since merge is associative. The idea with merge sort, is you only want to merge lists if they are roughly the same length and this helps you do it (see Chapter 12).
577-
Write the associtative binary operation `merge` which can combine two sorted arrays into a sorted array.
576+
**Exercise:** If you want to implement [merge sort][merge-sort] you can use exactly the same device, since merge is associative. The idea with merge sort, is you only want to merge lists if they are roughly the same length and this helps you do it (see Chapter 12).
577+
Write the associative binary operation `merge` which can combine two sorted arrays into a sorted array.
578578

579579
**Exercise:** When we become grownups we learn about advanced data structures, such as [binomial forest][binomial]. They use the same idea. Learn about this data structure and try to figure out where
580580
the counter could be used.

11_min_1_2.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ for your future work.
3131
I pick this algorithm because it allows us to learn how to do decomposition
3232
and learn these components like `list_pool` and `binary_counter` along the way.
3333

34-
Let me sketch the grand plan of the whole alogorithm.
34+
Let me sketch the grand plan of the whole algorithm.
3535

36-
1. We already showed that we want to arrange our comparisons like a tennis tournmant,
36+
1. We already showed that we want to arrange our comparisons like a tennis tournament,
3737
and `binary_counter` helps us do this.
3838
Instead of comparing by left reduction, we compare by balanced reduction.
3939

4040
2. We also want to keep a history for each element of all
4141
the other elements which they have beat.
4242
This history will be used to determine the second-place guy.
4343

44-
We will store this history in a list (using `list_pool`)
45-
along with each element in the binary counter.
46-
Note that the counter works on generic elements, so it doesn't
47-
need to be modified to know about this history tracking.
44+
We will store this history in a list (using `list_pool`)
45+
along with each element in the binary counter.
46+
Note that the counter works on generic elements, so it doesn't
47+
need to be modified to know about this history tracking.
4848

4949
From where we are now, it should only take 4-5 lines of code
5050
to write `min_element_1_2` along with type scaffolding.
@@ -100,7 +100,7 @@ Now define the pool. We do know its type:
100100
Notice that we use `std::min_element` on our list pool.
101101
Will that work?
102102
Yes, because we added iterators to our list pool.
103-
Define our `iterator` type;
103+
Define our `iterator` type:
104104

105105
typedef typename list_pool<I, std::size_t>::iterator iterator;
106106

@@ -201,7 +201,7 @@ we can define the final missing types and the signature:
201201

202202
typedef op_min1_2<I, size_t, compare_type> op_type;
203203
typedef binary_counter<op_type> counter_type;
204-
typedef typename op_type::argument_type result_type;
204+
typedef typename op_type::argument_type result_type;
205205

206206
// ...
207207
}
@@ -238,7 +238,7 @@ brought up this example:
238238

239239
Obviously what you are trying to do is extract `T`'s `value_type`
240240
and use it here.
241-
Let us try to to follow the committees logic.
241+
Let us try to follow the committees logic.
242242
The logic says maybe `T::value_type` refers to a static variable
243243
in `T`, which it could be of course.
244244
But, don't you know from the context that it's supposed to be a type?

12_merge_sort.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ I wanted this job really badly.
1818
A friend of mine who
1919
worked at this Institute recommended me to this group.
2020
I knew I was going to go
21-
there for for an interview and I'd have to say some wonderful things or they
21+
there for an interview and I'd have to say some wonderful things or they
2222
would not give me a job.
2323
Right before my interview, terrible thing happened.
2424
I ate some raw fish and it was very tasty but within
@@ -56,8 +56,8 @@ there is this thing called associativity.
5656
I realized that this idea will work as long as the operation is associative.
5757

5858
This became my central theme.
59-
how could I talk about associative operations?
60-
how could I write algorithms like that?
59+
How could I talk about associative operations?
60+
How could I write algorithms like that?
6161
When I came to United States somewhere along the way,
6262
maybe in Austria, I realized that merge was associative
6363
It was a very big deal because I never even thought about merge in terms of `+` and `*`, but merge is associative.
@@ -141,13 +141,13 @@ There are several [iterator concepts][cpp-iterator-concepts] in STL[^sgi],
141141
all of which we have mentioned before:
142142

143143
- [`InputIterator`][cpp-input-iterator]: can only advance forward and once advanced, iterators pointing to previous elements become invalid.
144-
- [`ForwardIterator`][cpp-forward-iteartor]: can advance forward and have iterators pointing to previous elements.
144+
- [`ForwardIterator`][cpp-forward-iterator]: can advance forward and have iterators pointing to previous elements.
145145
- [`BidirectionalIterator`][cpp-bi-iterator]: can move iterators forward and backward.
146146
- [`RandomAccessIterator`][cpp-random-iterator]: can advance iterators by arbitrary steps in constant time (like pointers).
147147

148148
[cpp-iterator-concepts]: https://en.cppreference.com/w/cpp/iterator
149149
[cpp-input-iterator]: https://en.cppreference.com/w/cpp/named_req/InputIterator
150-
[cpp-forward-iteartor]: https://en.cppreference.com/w/cpp/named_req/ForwardIterator
150+
[cpp-forward-iterator]: https://en.cppreference.com/w/cpp/named_req/ForwardIterator
151151
[cpp-bi-iterator]: https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator
152152
[cpp-random-iterator]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
153153

@@ -220,9 +220,9 @@ on a built-in type instead of a class.
220220

221221
foo(x,y)
222222

223-
However Alex doesn't follow this convention:
223+
However Alex doesn't follow this convention.
224224

225-
[^member-functions-on-primtives]: Other programming languages, such as Swift, allow you to extend primitive types like `int` with additional member functions.
225+
[^member-functions-on-primitives]: Other programming languages, such as Swift, allow you to extend primitive types like `int` with additional member functions.
226226

227227
[iterators-must-go]: https://accu.org/conf-docs/PDFs_2009/AndreiAlexandrescu_iterators-must-go.pdf
228228

@@ -338,7 +338,7 @@ inheritance, smart pointers, or read certain books.
338338
Now I'm going to teach you to use `goto`.
339339
The greatest authority in computer science wrote a famous letter to
340340
communications of ACM called, ["Go To Statement Considered Harmful"][harmful].
341-
There is is nothing harmful in the computer.
341+
There is nothing harmful in the computer.
342342
The computer is good.
343343
It has an instruction called [JMP][jump] (or branch).
344344
If it's there, why not use it?
@@ -475,7 +475,7 @@ Modern processors try to predict which
475475
way a condition is going to go.
476476
If you look at our branches, the probability
477477
of going one way or the other is 50 percent.
478-
That's literally the worst thing which which could happen.
478+
That's literally the worst thing which could happen.
479479
I'm entering the territory where I haven't done work yet.
480480
I haven't tried see whether some kind of predication avoidance of `goto`
481481
could be done.
@@ -498,7 +498,7 @@ There is no code, it's just a way of invoking our merge function.
498498
It has 5 arguments, and we need a binary function.
499499

500500
template <typename I, typename Compare>
501-
// I is Linked Iteratork
501+
// I is Linked Iterator
502502
struct mergesort_linked_operation
503503
{
504504
typedef I argument_type;

13_searching.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Once upon a time I believed ranges come in two kinds[^eop-range-kinds].
271271

272272
1. **Bounded ranges**: Ranges bounded by a first and last iterator/pointer.
273273
2. **Counted ranges**: Ranges constructed from a first pointer/iterator and an
274-
interger `N`.
274+
integer `N`.
275275

276276
Which one is better?
277277
Both are good, and both are different.
@@ -322,7 +322,7 @@ So let's try writing `find_if_n`
322322
Everyone loves to make non-standard names.
323323

324324
[^wrapper]: I find this comment amusing because
325-
Alex just got done talking about why `find_if_not`was such a helpful contribution
325+
Alex just got done talking about why `find_if_not` was such a helpful contribution
326326
It's not clear how to reconcile his advice to carefully considering convenience of user,
327327
with this comment about not wanting to provide convenient interfaces for algorithms.
328328

0 commit comments

Comments
 (0)