Live data from Hacker News

Top algorithms in interview questions

geeksforgeeks.org

11–20 of 70 posts

Re: Top algorithms in interview questions

#11

I genuinely want to know where people use these algorithms in their code. I'm a non CS dev to begin with so may be I don't know where to use them since I didn't get formal CS education. This way of interviewing is not what I prefer. I have been told I write better code than my CS grad peers but I have no clue about these algorithms and data structures. What do you guys think about this form of interview?

As a working developer for 20 years, the majority spent at Microsoft, I'd say that I have to understand data structures and algorithms in general, but I certainly do not need to know how to implement the ones that have names.

Re: Top algorithms in interview questions

#12

I genuinely want to know where people use these algorithms in their code. I'm a non CS dev to begin with so may be I don't know where to use them since I didn't get formal CS education. This way of interviewing is not what I prefer. I have been told I write better code than my CS grad peers but I have no clue about these algorithms and data structures. What do you guys think about this form of interview?

All other things being equal, someone who understands these algorithms/data structures and how/when to use them would be preferred over someone who hasn't put time in to get familiarized with them. I think in many positions it probably isn't necessary to have knowledge of how to implement from scratch -- yet again, if the company could find someone that gets it, they may produce overall more efficient solutions. Whet…

All other things being equal, someone who understands these algorithms/data structures and how/when to use them would be preferred over someone who hasn't put time in to get familiarized with them.

Correction: all other things being equal, the person who does better on an algorithms/data structures pop quiz is more likely to be a recent college graduate who you can pay less and treat worse than an established developer who's forgotten most of this stuff and just looks it up when/as needed.

Re: Top algorithms in interview questions

#13

I genuinely want to know where people use these algorithms in their code. I'm a non CS dev to begin with so may be I don't know where to use them since I didn't get formal CS education. This way of interviewing is not what I prefer. I have been told I write better code than my CS grad peers but I have no clue about these algorithms and data structures. What do you guys think about this form of interview?

Sometimes just moving a .find into a precomputed hashmap can be the difference between O(n^3) and O(n). The difference is important with n as low as 100.

It's that intuition which is valuable, not the implementing of algorithms by name.

Re: Top algorithms in interview questions

#14

Earlier quoted context omitted.

All other things being equal, someone who understands these algorithms/data structures and how/when to use them would be preferred over someone who hasn't put time in to get familiarized with them. I think in many positions it probably isn't necessary to have knowledge of how to implement from scratch -- yet again, if the company could find someone that gets it, they may produce overall more efficient solutions. Whet…

All other things being equal, someone who understands these algorithms/data structures and how/when to use them would be preferred over someone who hasn't put time in to get familiarized with them. Correction: all other things being equal, the person who does better on an algorithms/data structures pop quiz is more likely to be a recent college graduate who you can pay less and treat worse than an established develop…

In terms of simply getting hired/passed the interview, yes, either a recent grad or someone having studied the algorithms prior to the interviews will probably do best. I won't argue it's annoying to study for an interview.

I still think someone who understands these and has studied them will be in better shape to understand when/how to use such things in situations on the job (even if they can't be reproduced in a pop quiz scenario by the person). Maybe those situations will matter to the company, and maybe they won't.

Re: Top algorithms in interview questions

#15

I genuinely want to know where people use these algorithms in their code. I'm a non CS dev to begin with so may be I don't know where to use them since I didn't get formal CS education. This way of interviewing is not what I prefer. I have been told I write better code than my CS grad peers but I have no clue about these algorithms and data structures. What do you guys think about this form of interview?

Do you really find you can ignore data structures and algorithms in your work (and if so, what sort of work do you do)?

Let's look at it in a different way: I have a CS education, and have worked professionally since the 90s. In my resume there's things like: - A code generator that took as input sources - High performance RMI libraries for a phone company - A entire retail system, from POS, to warehousing, reporting and PCI-DSS compliant key exchange systems - Distributed systems that coordinate work between thousands of nodes - A machine learning project that was recently mention in HN. - Migrated most computing in a fortune 50 company to the cloud

There are far more storied careers than mine in HN, but this is not a career of someone that spent their days writing CRUD apps in visual basic: I worked on fun things. Some of that worked involved algorithms: many of them very complicated. However, since I left school, other than in interviews, I never had to touch a high percentage of the algorithms in that page. Let me go a section at a time:

- I have used graphs plenty of times, but I can't recall using any of those algorithms directly. Yes, not even BFS. - I had to do linked list-like operations when I was writing in C at the beginning of my career. Not a single time since. - Zero dynamic programming. Nada. - Not a single manual sort algorithm, not a single manual search algorithm. - There's been plenty of trees, but none of the operations covered there. They were either provided by the libraries underneath, or never came up. - Number theory? Nothing from that list. I have implemented HyperLogLog though. Just don't ask me to do it from memory. -Early in my career I had to deal with some bit manipulation. I've not had to touch it in years. -Not a single one of those string/array manipulation ops

So my answer to the grandparent is that you can have a long, fun, not CRUD app career doing fun things without having to implement those algorithms once, because they are done for you. The algorithms those jobs need in practice are often harder, but you don't have to have them memorized: Some you go look for papers that solve your problems, others you develop yourself (and be afraid of that one, as I have seen a mathematician come up with a 5 page proof for an algorithm that only did what we needed in a parallel universe where latency is zero)

What almost every professional programmer has to understand what an array, a list, a set, a tree and a map are, and to go check the performance problems of specific implementations if it matters at the time. Almost every other interesting thing I have done was only relevant a small percentage of the time, and I could look up.

Interviews ask the questions they do because they match what is taught in a small subset of CS classes. We could teach other algorithms in those: Some of the ones I had to use would fit in said classes, instead of the ones we have. They can be implemented in under an hour too. However, nobody asks for them in interviews, because the people that come up with interview questions haven't solved them before.

So my point is not that you can ignore data structures and algorithms: You'll use some no matter what. But there is no subset of algorithms harder than a loop that every programmer uses in a regular basis, or data structures that we manually implement. We just ask for things that come from those same CS classes because we have no idea of how to assess if someone is any good, and the algorithm classes were some of the harder ones in college, so we assume that if you have them memorized, you must be pretty good. And we assume wrong.

Re: Top algorithms in interview questions

#16
What a typical, uninspired, and pretentious list. I've recently started to opt out of interviewing people because I'm often teamed with someone that will Google one of these, think they're some sort of genius, and proceed to make some poor twenty-year-old feel like a doofus for not knowing the algorithm for a convex hull.

Speaking of which -- seriously? The only time I even had to LOOK at that algorithm was when I read a very old game programming book -- before I even went to college, mind you -- and generating pixel-perfect collisions for arbitrary polygons was one of the chapters (the game example was one of those meteor blaster clones).

I have strong feelings about this and I think this article is a complete waste of time, not to mention lazy (it looks auto-generated, anyway) because it perpetuates the idea(l) of making the software engineer interview process as arcane and difficult as possible.

Re: Top algorithms in interview questions

#17
post #16

What a typical, uninspired, and pretentious list. I've recently started to opt out of interviewing people because I'm often teamed with someone that will Google one of these, think they're some sort of genius, and proceed to make some poor twenty-year-old feel like a doofus for not knowing the algorithm for a convex hull. Speaking of which -- seriously? The only time I even had to LOOK at that algorithm was when I re…

maybe they want to skew their workforce to select for youngsters - recent grads would be best at these sort of things, cause as you say no-one writes these things in real life and if you do, you reach for the books. Glad those days are behind me, but it is a shame that this nonsense passes for interviewing.

Re: Top algorithms in interview questions

#18

I genuinely want to know where people use these algorithms in their code. I'm a non CS dev to begin with so may be I don't know where to use them since I didn't get formal CS education. This way of interviewing is not what I prefer. I have been told I write better code than my CS grad peers but I have no clue about these algorithms and data structures. What do you guys think about this form of interview?

Do you really find you can ignore data structures and algorithms in your work (and if so, what sort of work do you do)?

Im a frontend dev by day. Golang/rust by night where Im in the need of learning DS/Algo anyway.

Re: Top algorithms in interview questions

#19
post #15

Earlier quoted context omitted.

Do you really find you can ignore data structures and algorithms in your work (and if so, what sort of work do you do)?

Let's look at it in a different way: I have a CS education, and have worked professionally since the 90s. In my resume there's things like: - A code generator that took as input sources - High performance RMI libraries for a phone company - A entire retail system, from POS, to warehousing, reporting and PCI-DSS compliant key exchange systems - Distributed systems that coordinate work between thousands of nodes - A ma…

I feel like recursively descending some object isn't some obscure thing and there is DFS for you.

Re: Top algorithms in interview questions

#20
Would a better way to interview be questions like:

1) I have an array of 1000 integers, which of these would be the best way to sort them a) quicksort b) bubblesort...

2) what sort of structure would you use to store a list of numbers and strings 1) dictionary/hash 2) two arrays ...

and so on. These would give you the certainty that they know which is which, you could ask give reasons to see if they mention O() and so on.

IRL it's very seldom that you write one of these structures, but you use them all the time and need to know which one to use when.

Post reply on HN