Learning DSA as a working professional
Hello, blog!
Wanted to share a quick life update of how I've been spending my free time in active development of myself. As Jim Rohn once said, always work harder on yourself than you do on the job. Formal learning will make you a living but self-learning will make you a fortune. While I'm working on my fortune; a subject of interest to me has been Data Structures and Algorithms.
Here are some tips:
- Start with why?
- I think for me it is to have a better understanding of the systems that I'm dealing with and eventually have my own startup.
- Subscribe to a course or plan out things to learn [1]
- Get an accountability partner [2] - this is something I came across from my Toastmaster's and its been super helpful.
- Dedicate a certain time everyday to study for this!
- Upload to GitHub everyday for those green squares
- Try to teach what you learn to other folks - maybe join a study group if possible.
Here's something beautiful that I came across recently. Say you're given a linked list of binary numbers (0s and 1s) and need to convert this to a decimal number.
1 -> 0 -> 0 -> 1 -> 0
If you were to do this problem by hand; here's how you'd do it. You'd go from right to left and calculate:
0 * 2^ 0 = 0
1 * 2^ 1 = 2
0 * 2^ 2 = 0
0 * 2^ 3 = 0
1 * 2^ 4 = 16
adding them all up -> 18
However, in a linked list; each node only knows about itself and has a pointer to the next node. So the '0' node in 1s place does not know about the '1' in 10s place. How would you solve this problem?
Turns out; there's a beautiful way of looking at number base:
decimal = 0
base = 2
temp = self.head
while temp:
decimal = (decimal * base) + temp.value
temp = temp.next
It works because each step applies the positional number system rule, multiplying the running total by the base (shifting digits left) and then adding the current digit’s value.
[1] https://www.udemy.com/course/data-structures-algorithms-python/?couponCode=PYTHON-SEP2025
[2] https://www.youtube.com/watch?v=C0OIRMrjcZE
Comments
Post a Comment