r/AskProgramming • u/narajaon • May 02 '20
Is being very good at data structures and algorithms worth it ?
Hello, I'm practicing on hackerrank at the moment because I want to improve my data structures and algoritms skills for future interviews.
The thing is, everytime I successfully solve a problem and go to the discussion sections there's almost always somebody who will find THE perfect solution in terms of space / complexity.
So my question is for those of you who are really good at those types of problems, was it worth it ? Are you working at a FANG-like company right now ? Are you able to sell that skill when the interview is more about building apps than creating an algorithm ?
ps: sry for bad engrish
edit: Thanks for the replies ! Maybe I should have emphasized more about the "very good" at DSA part. I know the time complexity of arrays, hash tables, BST etc. I also know some classic sorting algorithms and tree traversals. I did not ask if learning DSA is useful because obviously it is but to what degree ?
2
u/okayifimust May 02 '20
Remind me again what the typing-code part of programming has, other than essentially data-structures and algorithms?
The thing is, everytime I successfully solve a problem and go to the discussion sections there's almost always somebody who will find THE perfect solution in terms of space / complexity.
Well, yes. All of those problems are very straight forward, and they are written in the expectation of a specific solution. Surprisingly enough, it turns out that there is a known, optimal solution.
So my question is for those of you who are really good at those types of problems, was it worth it ?
Yes, I think it's worth a lot of effort to become a better programmer. Understanding what the optimal solution is, what trade-offs I am making, and why, makes me better. IMHO, as long as you can't do any better, you're not the right person to judge if what you're doing is good enough or not.
And if it actually bothers you, then you need to learn and practice more.
Are you working at a FANG-like company right now ?
I'm not even trying. I find it odd that you would value success or worthiness at, what, the top 5% and no less?
Do you do sports? Do you exercise? Are you taking part in the Olympic games? Because if no, you're clearly wasting your time, right?
Are you able to sell that skill when the interview is more about building apps than creating an algorithm ?
What's with the bizarre view that any program would be comprised form anything but algorithms?
And I think it's that exact approach that is making struggle, and keeps them from excelling. They think that there is programming on one hand, and on the other, there's "algorithms" that you may or may not chose to make part of your programming.
And that translates to not giving a shit if the solution to a problem is good, except when you have decided it is worthy of utilizing some "algorithm" - whereas, in reality, you're always using an algorithm - and it's just a question of picking the right one, or better, of making a good choice.
1
u/narajaon May 03 '20 edited May 03 '20
Remind me again what the typing-code part of programming has, other than essentially data-structures and algorithms?
I can think of many things actually: architecture, design patterns, DRY / KISS code, mastering the limits / edge cases of your programming language, writing meaningful tests, knowing different paradigms...etc. Pretty sure there's a lot more.
I know the trick of your question lies in your usage of the word essentially and every app is just some algorithm using data structures. I don't think that kind of argument is constructive though.
edit: thank you for your elaborate answer !
1
u/okayifimust May 03 '20
I know the trick of your question lies in your usage of the word essentially and every app is just some algorithm using data structures. I don't think that kind of argument is constructive though.
IT was meant to be constructive, and I am not trying to trick you. The key is not "essentially", it is the part about the written code.
I can think of many things actually: architecture, design patterns, DRY / KISS code, mastering the limits / edge cases of your programming language, writing meaningful tests, knowing different paradigms...etc. Pretty sure there's a lot more.
I am not saying that these are irrelevant at all. But they don't stop your program being a bunch of small algorithms combined into one big algorithm.
The more you understand the common patterns, best-practice solutions to known classes of problems, the easier you will find it to write code that's does things well, rather than just looks well. Both aspects are important. You can just write code the correct way, and as much as using appropriate design patterns can be part of your flow rather than after thought, so can your choice of algorithms.
2
u/jnguyen7410 May 03 '20
As someone who does interviews for FANG, let me put it this way: for your job, it's not important that you know all the algorithms or data structures. We live in the age of the internet, so if you forgot how to do a DFS/BFS on a tree, you can look that up easily. But if you want to land a job and be proficient in that role, you'll have to study those extensively.
To that point however, you need to understand the sheer volume of people that apply to companies like FANG. on top of that, a lot of them are brilliant engineers, but we can't accept them all. So the best way to reduce their numbers is to test their knowledge, their experience, and their preparedness.
That last point is particularly important because we have very few interviews between the technical phone screen and getting hired. How can we figure out which candidates will excel in our company? How do you know what percentage of their resume represents their actual skilll set? How can we test their efforts and hard work? That all comes down to these coding interviews.
Don't worry about finding the "perfect" solution. All good questions have several acceptable answers, and if there's only one right answer, that's a gating question and usually not allowed (at least at my company). With that in mind, it's always good to know several different ways to solve a problem so you can show the interviewer your flexibility.
Don't get me wrong, knowing the info is super useful and the two times you need it, you'll be glad you know what the solution is. Also, I know that the current interview practice is far from perfect, but this method currently provides us concrete signals that we can assess objectively to help determine the best candidates.
2
u/narajaon May 03 '20
Ok so first of all, thank you very much for your elaborate answer. Everything you wrote was something I kinda felt but failed to put my finger on.
Knowing what the industry expects and how DSA will be useful for my job is actually way more motivating than "you have to because that's what a good programmer does".
1
u/Kikawaru May 23 '20
That's bs
1
u/jnguyen7410 May 23 '20
Lol I never said it's fair or perfect, but it's the best way to reduce the numbers to a single percent or less. If you can show me a better method of properly assessing a candidate while highlighting the best of the best to take what limited slots there are, feel free to PM me and I can bring it up with the interview board.
It's not that we want to torture candidates, you have to remember we were once candidates ourselves. And it sucks that it headed for a trend of obscure and rarely used algorithms, but it's harder to separate out the great from the brilliant. Plus, it's actually becoming harder and harder to find questions like the ones I mentioned (at least at my company). Most of the questions either revolve around something that relates directly to what you'll be doing or at least should be something all engineers at the company should know how to solve (depends if its the tech phone screen or onsite). With that said, there's only so many questions out there.
22
u/rabbotz May 02 '20 edited May 02 '20
good at those types of problems ... Are you able to sell that skill when the interview
First off, please don't think like this. Your career will last decades, thinking of your skillset in terms of how to pass an interview is the path to having a mediocre career. Be really good at what you do and 5+ years in you will be in high demand at even the best companies. I'm not saying don't study for interviews, I'm saying don't think of your skills so narrowly.
To answer your question, being good at data structures and algorithms is probably the second most important skill when developing software (after actually knowing a programming language lol).
I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important.
-Linus Torvalds
This quote is spot on. When you are designing and writing software, if you can map your problem to the right data structures the code and algorithms become relatively very easy.
6
u/ElllGeeEmm May 02 '20
First off, please don't think like this. Your career will last decades, thinking of your skillset in terms of how to pass an interview is the path to having a mediocre career. Be really good at what you do and 5+ years in you will be in high demand at even the best companies. I'm not saying don't study for interviews, I'm saying don't think of your skills so narrowly.
I don't think you're entirely wrong, but you have to realize not everyone has the privilege of worrying about 5 years from now today. There's nothing wrong with someone looking for their first full time developer job being entirely focused on getting their foot in the door. Once they've done that, I absolutely agree that they should be looking to use that opportunity to expand their skillset, not get ready for the next interview.
6
u/fullstack_guy May 02 '20
No. It will help you get a job because for some reason sticking you on a whiteboard and asking you to invert a binary tree is considered a standard interview tactic, but you literally will never do this at any normal dev job. Those skills are essentially worthless in the real world. If you run into this sort of interview, be fully aware that you are being asked to show proficiency at a task that is not useful for the position. Reflect about what that says about the company and team there.
4
u/HeinousTugboat May 02 '20
Hire people based on their ability to write overwrought technical code, wind up with teams full of people only writing overwrought technical code...
1
u/scandii May 02 '20 edited May 02 '20
there's two types of programmers; those that are computer scientists and those that aren't.
if you want to be paid top dollar you also want to be a computer scientist.
but keep in mind, you learn this stuff at university where you get your degree in computer science.
as a "self-taught" computer scientist, I would let my CV do the talking. nobody is interested in that you can identify an algorithm, they're interested in why that algorithm is useful to solve this particular problem.
1
u/narajaon May 03 '20
So what you are saying is basically that if you did not graduate in CS you should build a portfolio and apply to companies that don't test your DSA skills ?
1
u/scandii May 03 '20
exactly.
you won't find a ton of people working as programmers in big name companies without a degree - and if they do they didn't get hired as a junior.
1
u/Mad_Jack18 May 02 '20
Is it ok for me to take Computer Science, even though let's say that I got my Bachelors in Information Technology?
2
u/__r17n May 03 '20
If your goal is to join a company that asks data structures and algorithm (DSA) questions, then it's absolutely worth it (necessary).
Don't get discouraged by the "perfect" answers for the harder type questions. There's often multiple solutions and at times a "technically optimal" one among them - maybe there's two O(nlogn) solutions, but one is technically more optimal than the other - no need to stress about this. Sometimes they involve a trick, which if it's a good interview question, should not be required.
However, if you're giving an O(nlogn) solution, but there's actually an O(logn) one, you should learn how to do it. Learn from these solutions in the discussion sections.
Regarding the "selling the skill in a non-hackerrank/leetcode style interview", the answer is a resounding "no". I would recommend 1. knowing the interview style of companies you're applying to (DSA vs. domain-knowledge). 2. Grouping your interviews by interview type. i.e. if your goal is to get into "FANG-like", apply to them at the same time and set up interviews in the same weeks. If no success here, brush up on the domains you're applying for and then repeat.
2
u/n1c0_ds May 03 '20 edited May 03 '20
You get paid to solve problems. Not technical problems, business problems. If you solve business problems, you will make a lot of money. You don't need to be a good programmer to do this.
Algorithms and data structures are a box of tools. Each tool solves a problem. You don't need to know each tool perfectly, but you need to know which tool you need to solve your problem.
If you don't pick the wrong tool, you can write bad software. If it's bad enough, it becomes a problem. A business problem.
I like those articles a lot. I think they answer your question:
https://www.kalzumeus.com/2011/10/28/dont-call-yourself-a-programmer/
1
1
May 03 '20
Yes and no. The important thing is that you understand the concepts and understand when they’re necessary, but it’s also important to note that it’s not always necessary to use the most efficient algorithm or data structure. It truly depends on the application, environment and the project as a whole.
But they are important.
1
u/AndreaPollini May 03 '20
Knowing data structures and algorithms make you good at problem solving and abstraction. I don't mean you must know every algorithm, you must know how to use algorithm to solve problems (Knowing what a DS looks like helps you to use it as an abstract problem solving tool
1
u/coder970 May 27 '20
Yes, you need to be good at DS atleast to pass the tech interviews of core companies. You should start practicing DS problems for Tech Interviews - Here's a really great list to get you started.
1
u/not_perfect_yet May 02 '20
I looked into hackerrank and my best guess is that it's a negative filter: the longer you stay with it and the more time you invest doing brain teasers, the more it shows you can't recognize what a waste of time is.
The one that made me "conclude" this, was a challenge that required you to solve a problem without loops.
And that really just disqualifies everyone involved I think. Loops exist to solve a problem, effectively and efficiently. People who avoid loops for no good reason aren't smart. People who pose challenges like that aren't interested in good solutions.
I know there are solutions, technically you have to be clever to find them, but it has nothing to do with "getting stuff done".
Except for the bits that are basically tutorials, "do you understand what an array is and how to access elements". I wouldn't give someone like that a "rank" though. If someone advertises him/herself as "can program", I assume that's included.
1
u/ElllGeeEmm May 02 '20
That's not a problem with data structures and algorithms not being important, that's a problem with how hacker rank asks questions. I would recommend looking into project euler as a better alternative if you want questions that will require you to properly use data structures and algorithms without forcing some arbitrary requirements on you like not using loops.
1
u/TheChessLobster May 02 '20
I think one thing that they don’t emphasize in school (at least for me when I was in school) is the idea that different projects or even classes are less important speed wise than others. Like if something is only being called a single time, who cares about its complexity. But if a billion records are being pushed through it, probably best to optimize.
2
u/vorpal_potato May 02 '20
They do usually teach Amdahl's law, but they don't always spell out its implications.
56
u/Loves_Poetry May 02 '20
Finding THE perfect solution is more about showing off among programmers. Employers don't care so long as the solution is fast enough. It's the difference between a design you can put on your webpage and one you can put in a museum. The first one does the job. The second one makes you famous, but has also way overshot its goal