Posts

Showing posts with the label DSA

Learning DSA as a working professional

Image
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 how my contributions look; I'm sure you can clearly tell how I'v...

Binary Search Algorithm

Image
Binary Search Figure [1] Binary Seach Algorithm applied to a descending order list Let's say we have an ascending-order sorted list of numbers as given below: number_list = [6, 12, 24, 39, 42, 43, 45, 89] Say we were tasked with finding whether a particular element was in the list or not, the simplest way that would occur to us is to use a 'for' loop.  target = 39 for num in number_list:   if num == target:     print(f"{num} is in number_list.") This works but say, we have a huge list of about a million or even a billion values, what would be the worst-case time complexity of such an operation? It could be that the target is the last item in the list, which results in the time complexity being O(n). So, let's think about a better way of solving this problem. Now, we know that the list is ascending-order sorted which means if we check a random number in the list and the number is bigger than our target , we can be sure that our target if it is in, will be to th...