Hi Tim Becker! Thanks a lot, I appreciate it 🙂
Let's go with your question below:
```In your opinion, which are the algorithms and data structures a data scientist would benefit from knowing the most?```
Ah, tricky one... They would benefit from all of them? 😄
OK, kidding, I don't expect you let me get off the hook so easily 😛
Let's see... of course, all algorithms related to machine learning, because it would help them to understand better how to apply these techniques.
Probably MapReduce programming model is also going to be gold.
Then besides that I'd say it really depends on the area one is focusing on 🤔
```What is your background and how did it lead you to writing this book? What was your motivation to learn more about algorithms?```
I have a master degree in computer science, major in AI and algorithms.
Then I spent most of my career working on web applications and data processing, but I always tried to keep up to date and do some research on algorithms.
Evolutionary algorithms, graph theory, are my passion (within CS), and writing a book about them seemed a good way to combine business and pleasure
```Why did you use Java and Javascript for most of the examples (github)?```
And Python as well (OK, a bit less!)
So, JavaScript: because when I started working on this book, a long time ago, the idea was to focus on "Algorithms and DSs in JavaScript", or in general for the frontend.
So I had written a lot of code in JavaScript, and moreover I was working on a library for graphs in JavaScript (lately rewritten into https://github.com/mlarocca/jsgraphs (opens in a new tab))
Then Manning accepted to publish the book and we pivoted to a more broad audience, so I wanted to add a typical backend language, and Java was the mainstream one with which I was the most comfortable
```If you are working on a programming task, how to you approach the challenge of finding the best algorithm or data structure for the task?```
Ah, that's tricky! How much time do we have to talk about this? 😄
So there are many aspects to keep in mind, but one thing applies IMHO: while you don't always need the absolute best possible solution, the most important thing is to avoid all the bad solutions.
Let me explain: it might change little if you use `mergesort` instead of `quicksort`, but it's more important that you avoid `selectionsort`, which is definitely going to be slow.
Or even more, it can be fine using one of many heuristics that only slightly differ in their running time, but the important thing is to avoid brute-force search.
More specifically, I try this approach.
- First, I clarify the requirements, both in terms of goals and resources available
- Then, I start reasoning/researching about the possible solutions
◦ I look for existing libraries that I can use
◦ If nothing off-the-shelf works, I search inside the company who could have the knowledge to implement a custom solution
◦ Then weigh the options and how much time they would take
◦ I try to pick the best affordable option, say the one that could get me the most value within those requiring a reasonable time (depending on requirements) or anyway those that are below the median.
- Then once implemented I profile my code, and see if the algorithm is a bottleneck. If it is, and there is an available algorithm that (with some effort) can give an asymptotic improvement, I go for it. Of course this iterative approach only works if at the first step I choose a quick solution (either off-the-shelf or quickly implementable)