Ask HN: Is it necessary to know algo and ds to be a good programmer
Hi,
I am of the opinion that programming has the potential to solve a lot of problems that humans are currently facing. But I have heard people saying that to be a good programmer you need to have algorithms and data structures at your tips. Do you think learning algos will help me solve problems in a better way?
2 comments
[ 3.6 ms ] story [ 15.4 ms ] threadMore importantly, data structures are essential to just about everything you do as a programmer. Every program has some amount of data it needs to utilize as input or output and data structures inform everything from where and how you store it to how you work it (how you program against it!).
Here you see the crossover back to algorithms and further the importance of good fundamentals in algorithms: well-known data structures have well-studied algorithms for things such as creation, insertion, deletion, management, sorting, iteration, and more. Better knowing those algorithms helps you better understand the tradeoffs between data structures.
Using the right data structure with the right set of algorithms for that data structure for the given usage cases of your data is a huge part of programming and a big distinction between bad programs, good programs, and amazing programs.
One of the biggest weaknesses I consistently see is a lack of data structure and algorithm knowledge in developers. Here is why it separates you from the pack IMO. If you have the knowledge, you will not waste time selecting data structures that won't work for the use case long term. This doesn't mean you you will always be perfect, but you'll understand the tradeoffs during design and not have to implement it only to find out it won't really work. Algorithm knowledge goes hand in hand with data structures. If you know you have requirements to produce certain types of results you will change how you store data and which algorithms you use to search, sort and query it.
A lot of things I fix in other people's code is poor choices in data structures and algorithms. I did one a few years back which took a process that ran for about 8 hours to complete and made it run in less than 5 minutes. It was relatively simple, essentially they were trying to use really poor data structures for the type of data and calculations they needed to do and they kept trying to work within those. For my implementation, I modified the data structures and used more appropriate algorithms to accomplish the same thing in what was almost instant to them. Yes, I consumed more memory on application boxes, but it was considerably less strain on the database and network.