- Notifications
You must be signed in to change notification settings - Fork 6
10 clarifications #47
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
Conversation
justinmeiners commented Dec 14, 2021
- Includes PR some clarifications and typos in chapter 10 #45
@aharrison24 Here is an initial pass which mostly fixes typos and footnotes with your recommendations. I am still working on the larger reorg! Please bring them up if you think things should be different. I think everything we talked about, but I did remove some details from the Dirichlet proof footnote. |
I've gone ahead and read chapter 11 and had a good think about the algorithm. I think I have a reasonable understanding of what's going on now. There are certainly some things I would have appreciated knowing sooner. I've mentioned most of them in my in-line comments. A couple of minor extra things: In the I also think it would be very valuable to have a slightly extended example of how the counter works, where multiple elements are inserted. You could do an example where the elements are characters and the binary operator is |
I also realised that nowhere is it explicitly stated that the counter starts out empty and has elements pushed in to it one at a time. |
Co-authored-by: Alastair Harrison <aharrison24@gmail.com>
Co-authored-by: Alastair Harrison <aharrison24@gmail.com>
Co-authored-by: Alastair Harrison <aharrison24@gmail.com>
Co-authored-by: Alastair Harrison <aharrison24@gmail.com>
I pick this algorithm because it allows us to learn how to do decomposition | ||
and learn these components like `list_pool` and `binary_counter` along the way. | ||
| ||
Let me sketch the grand plan of the whole alogorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information was completely missing before. This explains that we will use the linked list to store histories, and that it doesn't effect the binary_counter implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really good!
| ||
Let us assume we have elements of type `T` that need to be paired or combined in some way, | ||
whether with `min`, `+`, `merge`, or any other assocative operation on `T`. | ||
What we can do is create an array called a "counter". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information now reinforces that we are talking about generic element T
with generic operation.
If there is a guy in slot 2 he has won 2 games, and so on. | ||
This structure will help us to only pair up elements that have the same power. | ||
| ||
The following example using `min` as the operation should make this clear. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This specific example uses the min
operation so we can more clearly talk about winners and losers.
0 1 ... 31 0 1 ... 31 | ||
x 0 ... 0 --> 0 y ... 0 | ||
| ||
Otherwise `x` wins: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example corrected.
10_binary_counter.md Outdated
y 0 ... 0 --> x 0 ... 0 | ||
What if the counter is full, and has no zero slots? | ||
That's called an an **overflow**. | ||
There is a close analogy between our counter and binary integer counting: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analogy between the two stated more clearly.
**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). | ||
Write the associtative binary operation `merge` which can combine two sorted arrays into a sorted array. | ||
| ||
**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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These other examples have been moved to exercises.
I just finished the "big" revision and I think I have been able to address most of your comments. I went back to the videos to review this section and found some helpful comments I missed which address many of your concerns. I have added comments to this code here indicating specific resolutions to concerns. |
I think that's a great idea, and added it to issue #48 . |
| ||
The second function applies the operation | ||
to all the elements left sitting in the counter. | ||
After we finish adding all our elements to the counter, they might not all be reduced to one element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This justifies the need for the reduce_counter operation and is a quote from Alex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all looking really good! I haven't had a chance to re-read both chapters from beginning to end. Will try to do that soon.
I pick this algorithm because it allows us to learn how to do decomposition | ||
and learn these components like `list_pool` and `binary_counter` along the way. | ||
| ||
Let me sketch the grand plan of the whole alogorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really good!
Co-authored-by: Alastair Harrison <aharrison24@gmail.com>
Co-authored-by: Alastair Harrison <aharrison24@gmail.com>
I have resolved those comments you left. I am going to merge this in for now as it is a significant improvement. Let's start a new PR for additional fixes if needed. (I will review your issue again.) |