Deliberate Practice, Algorithms, diary of learning on 12.04.2022.
Here is my application of principles of Deliberate Practice on 12.04.2022. I use the GitHub repository as a diary to easily save activity from any device and as self-observing feedback.
What did I do?
I have read these:
- https://www.quora.com/Why-is-recursion-so-hard-to-learn
- https://en.wikipedia.org/wiki/Tower_of_Hanoi
- https://www.quora.com/How-does-professor-Shriram-Krishnamurthi-teach-the-concept-of-recursion/answer/Shriram-Krishnamurthi
- https://upload.wikimedia.org/wikipedia/commons/2/20/Tower_of_Hanoi_recursion_SMIL.svg
- https://en.wikipedia.org/wiki/Recurrence_relation
- http://alas.matf.bg.ac.rs/~mi10103/predavanja/_ds2/DiscreteMath.pdf (part of recurrent equations section)
- https://www.cs.cmu.edu/~cburch/survey/recurse/hanoitime.html
- https://math.stackexchange.com/questions/229493/how-to-come-up-with-a-recurrence-relation
- https://stackoverflow.com/questions/30201391/how-to-write-a-recurrence-relation-for-a-given-piece-of-code
- https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)
- https://www.google.com/search?client=firefox-b-d&q=why+recursion+create+tree
- https://www.cs.cornell.edu/courses/cs3110/2012sp/lectures/lec20-master/lec20.html
- https://www.google.com/search?client=firefox-b-d&q=how+to+think+recursively
- https://levelup.gitconnected.com/how-to-think-recursively-solving-recursion-problems-in-4-steps-95a6d07aa866
- https://www.geeksforgeeks.org/recursion-practice-problems-solutions/ (try reading recursive solutions to get an idea of what’s possible)
- https://www.quora.com/Do-experienced-programmers-still-get-confused-while-writing-recursive-functions
- https://stackoverflow.com/questions/37224520/are-functions-in-javascript-tail-call-optimized
I should read:
- https://www.google.com/search?client=firefox-b-d&q=strong+mathematical+induction
- https://www.reddit.com/r/learnprogramming/comments/ajwi3j/why_is_recursion_so_hard/
I have reversed the singly linked list using recursion:
I decided to solve a problem to reverse a singly linked list. I did that because I thought I could get an idea of how to solve the tower of Hanoi if I solved other problems using recursion. So I tried to go back and solve the problem tower of Hanoi, but I didn’t have much success solving it. However, I realized that I didn’t know the recursive solution or see the solution at all, which led me to think I was thinking about the wrong thing. I’ve been thinking about “how to solve the tower of Hanoi recursively.” But I should probably think about how to solve it in any possible way and then figure out a recursive solution. I have been thinking ever since last Sunday what is the subproblem I need to solve to get the recurrence relation to the tower of Hanoi. Anyway, I even saw the recurrence relation. I couldn’t wrap my mind around it. I think I’m thinking about the wrong problems and can’t solve them. I keep jumping from one problem to another and end up without any solution, so I keep juggling problems instead of solutions. However, I can’t focus on solving problems because I don’t know if I’m solving the right problem. Therefore I should solve any problem and hope it’s the right one; if not, I have learned something valuable. I should take the most common steps from all articles I’ve read and use them to solve the problem using recursion.
Describe progress
- I am definitely not on the same level as last week.
- I have read advice on how to solve problems using recursion from many articles listed above.
- I tried to solve the tower of Hanoi but didn’t succeed for the past seven days. It made me believe I’m thinking about it wrong and don’t make any progress because of it. Another option is that I did make progress, but that problem requires higher cognitive ability because it’s more complex.
- I solved a problem to reverse the singly linked list. I hoped it would help me see how to approach other recursive solutions, but it didn’t. For that solution I used a terminating condition instead of a base case; I kept going to the next node while they existed, then as recursive calls unwrap from the stack, I assembled the single linked list recycling the old nodes and breaking circular dependency by removing the previous pointer to next and assigning a correct one below.
- I’ve been thinking about recursion everywhere I went since last Sunday.
- I am familiar with and somewhat comfortable with recurrence relations.
- I am starting to get used to terms from the articles I’ve read as opposed to last week when everything felt alien. That means the information is sinking in, and my mind is adapting.
- I started to use the GitHub repository as my diary, which is quite a fantastic idea.
I realized that the key to solving my unfamiliarity with recursion is persistence in the efforts I’m currently making. Self-conscious guiding of:
- What did I do wrong?
- What did I do right?
- What am I doing wrong?
- What should I change?
- Where can I get the following advice?
- What advice do I need?
I have accumulated a lot of information so far:
- Created a mental representation of tail recursion optimization
- Wrote an algorithm to reverse singly linked lists with a low effort which I couldn’t do before
- Realized that my mind feels heavy due to loads of information over the past few days. Regardless, I need to stay on the topic, and once it sorts out, I will see immediate progress in reasoning on recursive solutions.
- Read recursive implementation to see how other people do it to get an idea of how to do it.
- Read a lot of articles on the recursion topic. Just check how many links are up there.
What did I achieve?
I GOT THE IDEA!
CREATE A RECURSION TREE FOR TOWER OF HANOI
That should help me assemble recursion calls into a recurrence relation. Maybe it can even help me create the recursive call.
I realized that the mind has its own pace at which it can absorb information and is slow. Continuous exposure to unfamiliar causes the brain to adapt and change, which has to happen over time. It is a problem because the body is not used to feeling uncomfortable. It is trying to achieve homeostasis. That’s why the mind adapts. It’s working towards homeostasis, so my mind will adapt as long as I keep doing it.
I have not solved the tower of Hanoi problem, but I have achieved smaller goals.
- Getting comfortable with recurrence relations.
- Starting to gain the ability to reason about recurrence relations.
- Starting to feel comfortable writing recursive algorithms.
- Generating more ideas on how to solve recursive problems.
I have achieved all that in only seven days. That’s amazing! More than I would have expected. I am dissatisfied with a tower of Hanoi that seems too complicated, but maybe I should try a different solution if drawing a recursion tree doesn’t help me.
What did I do right?
- I continued to stay on the recursion topic over the past seven days.
- I tried different approaches to tackle the problem. They have yielded different results in only seven days.
- I implemented a recursive problem with a relatively low amount of effort. That means my mind is getting used to more complex recursive problems. Damn, that’s excellent!
- I searched for various answers on how to approach the recursive solutions.
What did I do wrong?
- I didn’t stick to one problem long enough. I didn’t read recursive solutions long enough, only for an hour or so.
- I couldn’t locate the right more minor problem to help me solve the tower of Hanoi.
- I couldn’t determine the exact steps to create a recursive solution.