Live data from Hacker News

Data structures and algorithms I actually used while working at tech companies

blog.pragmaticengineer.com

351–360 of 547 posts

Re: Data structures and algorithms I actually used while working at tech companies

#351
post #345

Early in my career, I interviewed at Google. One of the interviewer asked me to recite the algorithm for constructing a Convex Hull. Since I hadn't done anything related to convex hulls since my algorithms class as a sophomore in college (several years earlier), I couldn't remember all the details. At some point, I said, I know where in CLRS ( https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press... ) this is.…

For a company whose main claim-to-fame is indexing the web (rather than mirroring it in their databases), Google sure doesn't seem to understand that CS learning is done by mentally indexing textbooks (rather than mirroring them in your brain.)

That may be true. But then why hire someone with just look-up skills before hiring someone who really tries, and enjoys the challenge?

I'm interviewing engineers frequently and although I agree that the question asked by GP is maybe not the best it still gives the signal if someone is willing to power through a problem with minimal guidance and/or ambiguous constraints. Something I'm willing to find out at the peril of pissing off a few candidates.

Re: Data structures and algorithms I actually used while working at tech companies

#352
post #303

What is annoying about these interviews is that you are expected to have memoized all of the algorithms be able to implement them while someone is watching, on a whiteboard, in a very short amount of time. In my experience at Amazon and Google we all referred to books and colleagues when working through algorithms.

The grading rubrics for interviewers usually gives the candidate points for even mentioning particular algorithms, and I would hope that any decent interviewer would help you walk through trying to recall something. It's meant to be a design/application test, not a memory test

That was my experience. One interview question I was asked at Google boiled down to pathfinding on a graph. I suggested using A* and said "but I doubt I can write that on a whiteboard". The interviewer was fine with that, I got hired.

I did many SWE interviews at Google. I came up with my own question that obviously required using data structures and algorithms, but probably not something the candidate had ever thought about. Most people had a good thought process which was 90% of the question; some people arrived at the answer I thought was correct. Sadly, nobody ever came up with a better answer than what I decided was best. I was kind of hoping they would ;)

The problem with Google's interview system is that everyone gets to come up with their own questions. Some are bad! Some interviewers are bad! It takes the Hiring Committee a few candidates to recognize this and give the interviewer feedback about what's bad. But, that's why the HC exists and that's why you have 4 or more in-person interviews. The uncalibrated first-time interviewer does not have full veto power over hiring you. It can make for an uncomfortable experience (when is meeting new people and writing code on a whiteboard ever comfortable?), but overall the process does find good engineers.

The end result of the process, which I really liked, was that people on the team you're joining assume competency and don't explain simple things to you that you already know. I remember a few discussions in my first weeks at Google that blew my mind; we were talking about idempotency, and nobody needed to explain what it was. Every time I've ever used that word it derailed the meeting completely, requiring a remedial CS 101 course to bring everyone else on the team up to speed about that concept. Everyone at Google knows what that is, so you don't have explain it. It was nice. (This came up again when there was a discussion about state machines. Again, everyone knew what a state machine was, and used them somewhat regularly, so what was in my past life a discussion-derailing tangent was just a thing everyone knew.)

Re: Data structures and algorithms I actually used while working at tech companies

#353
post #228

I'm increasingly convinced that Algorithms-and-Data-Structure interviews are essentially being used as a proxy for: - General IQ. Can this person understand and apply complex ideas - Grit. Is this person hard-working enough to learn things that take time and effort It's the software equivalent of the NFL scouting combine. The goal is not to create a test that is similar to the day-to-day job. But rather, create a tes…

I'll get myself some down voting here... I kind of like asking questions about data structures and algorithms. I don't see them as simple black and white questions though. I see several values: 1) If you're a "computer science" degreed person, I expect basic understanding of basic algorithms and data structures. As for your basic job stuff, things like Java have multiple implementations of maps or hash tables you should have some idea when to pick one vs the other. I don't think that's off limits. 2) I like to ask a couple challenges or questions that sort of make the interviewee a little uncomfortable, not to get the answer but to work with them on it and see how they work through that situation. I intentionally try not to be cruel but I want them to think, I want to communicate with them as they sort through it, I want to see how that stuff goes. I've had 60+ minute conversations about engineering a professional grade hash table and the different things you have to consider, that's good stuff. The 3rd thing, and this is maybe more subtle, there is a gigantic difference between implementing quick sort and qsort in glibc, the same can be said about most algorithms and data structures and I think at least a cursory knowledge of that is an indication of some wisdom. Should you be asked to implement data structure x or classical algorithm y, understanding the mechanics beyond simply copying it out of a text book indicates some wisdom.

Re: Data structures and algorithms I actually used while working at tech companies

#354
post #351
post #345

Earlier quoted context omitted.

For a company whose main claim-to-fame is indexing the web (rather than mirroring it in their databases), Google sure doesn't seem to understand that CS learning is done by mentally indexing textbooks (rather than mirroring them in your brain.)

That may be true. But then why hire someone with just look-up skills before hiring someone who really tries, and enjoys the challenge? I'm interviewing engineers frequently and although I agree that the question asked by GP is maybe not the best it still gives the signal if someone is willing to power through a problem with minimal guidance and/or ambiguous constraints. Something I'm willing to find out at the peril…

I work with novel algorithms all day (I'm writing a decompiler.) The more I learn, the more I have confidence in the fact that I have absolutely no hope of inventing an algorithm that doesn't already exist; and that I shouldn't waste my time trying, when instead I could be spending that time digging through the nigh-infinite vault of potential solutions to my problem known as "the output of CS academia."

Software engineers aren't mathematicians. We don't invent algorithms or data-structures. That's not our trade-skill. And even actual mathematicians don't sit down to solve a real-world problem that no maths they're aware of directly solve—and then produce novel maths, and then use them to solve the problem—the very same year, let alone the same hour.

What I can do, as a software engineer, is to take algorithms that exist, and repurpose them or glue them together in novel ways that the designers of those algorithms never thought of, to do something new. Bitcoin, for one example, is a feat of pure software-engineering: it takes four or five existing well-known algorithms, and puts them together in a novel combination to solve a problem. I could maybe invent Bitcoin. But I can't invent Floyd-Warshall, if I don't know about it.

Google doesn't employ computer scientists (i.e. mathematicians who invent algorithms.) Alphabet does, under DeepMind and Waymo; but Google itself only employs—and only needs—software engineers.

Asking a software engineer, under pressure, to derive a novel algorithm, is a bit like asking a chemist, under pressure, to derive a novel class of chemical reaction; or a materials scientist, under pressure, to derive a novel material.

That's not the type of pressure that a real-world person in these jobs will ever be under. And moreover, it's precisely the type of pressure that people with experience in these positions have learned to mentally associate with "going in the wrong direction, toward wasted effort", flinch away from, and to turn around and study the literature instead.

It's ironic that Google expects its employees to all have university degrees. If there's one skill people who've gone to university are guaranteed to know (and to have built up a reliance on), it's consulting the literature.

Re: Data structures and algorithms I actually used while working at tech companies

#355
post #333
post #239

Earlier quoted context omitted.

There are lots of thing you can, but you should not.

What's wrong with a memoized recursive solution? Or a DP tail recursive solution? Tail recursive solutions are less buggy, easier to code, and easier to write than iterative ones. And they're much easier to prove the correctness of as well.

The memoized recursive solution is a good demonstration of how to use memoization to improve recursive function execution time. But it also seriously increases the memory requirements for many algorithms. If the question is "generate the first N numbers in the Fibonacci series", then memoization is a reasonable answer (though still not the fastest) since you actually need to generate and store every value anyways. If the question, instead, is "generate the Nth number in the series", then memoization will require an array of N values, when only 2 (at a time) are needed (which can still be generated recursively, but efficiently):

  (defun fib (n &optional (a 0) (b 1))
    (cond ((zerop n) a)
          (t (fib (1- n) b (+ a b)))))
With tail recursion, that should be as fast as the iterative solution and uses as much memory to store the intermediate values.

Of course, the Fibonacci series also grows incredibly fast, so practically speaking, unless your language supports arbitrarily large integers, you'll never generate even 100 elements of the series.

Re: Data structures and algorithms I actually used while working at tech companies

#356
post #316

Earlier quoted context omitted.

I call this distinction red flag versus green flag interviews. The typical hiring process is looking to quickly disqualify all but 1 person in the hundreds of resumes submitted to any open software engineering position. The hiring process you are proposing is looking to methodically search for all of the useful qualities in the candidate pool and determine how they can best be applied at the company. I think we can a…

> I think we can all agree someone can be a poor software engineer and not have any red flags. This has been something I find myself musing over every now and then for a couple years now. As we begin to relax barriers of entry, how do we maintain that some people fail/lose?

In a business, you are either don't hire them in the beginning or fire them in the end. Not everyone should be a software engineer (where would the users come from?). A large labor market organizes people into better jobs when they are passed over for or fired from a position.

Re: Data structures and algorithms I actually used while working at tech companies

#357

Early in my career, I interviewed at Google. One of the interviewer asked me to recite the algorithm for constructing a Convex Hull. Since I hadn't done anything related to convex hulls since my algorithms class as a sophomore in college (several years earlier), I couldn't remember all the details. At some point, I said, I know where in CLRS ( https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press... ) this is.…

I made the mistake of answering Google recruiter without a CS degree and "only" an EE/CompE and 10 years Software experience. Junior interviewer would not proceed past some algorithm question regarding boxes of pennies by weight, as he wanted a specific algorithm to be used in my solution, which I clearly didn't know. Recruiter then ghosted me, so F off Google for wasting my limited time like this.

Re: Data structures and algorithms I actually used while working at tech companies

#358
post #341
post #336

Earlier quoted context omitted.

Yea I interview (and have sat on HC) at Google, and interviewers who ask these types of questions really frustrate me. If your question requires having previously memorized or being able to come up with some tricky algorithm on the fly in 45 minutes and code a solution using it , your question is probably bad. I get why they ask them - they're easy to ask, they're easy to score, and when your question inevitably gets…

My favorite question to ask in software engineering interviews is one that I believe to be un-burnable. > It's 2140 AD, New York is under water up to X feet high. Buildings have been retrofitted with to withstand the water. You are in charge of keeping your building dry. If water gets in and damages the foundation, a few thousand people die or become homeless. > Design a system that ensures that doesn't happen. How c…

IMHO, this is not particular better than an algorithm question.

Why not just summarizes the traits of the technical skills you expect from the candidate, lay it out, and come up appropriate questions for each interview?

General software engineering interview does not work. But there can be more specific measures to improve the experience.

Re: Data structures and algorithms I actually used while working at tech companies

#359
post #304

This article is hurting its credibility right from the get-go by un-critically reproducing yet again this tired saw from Max Howell: > Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off. First, it's not remotely true that 90% of Google engineers use Homebrew, seeing as how almost all development is done on Linux (Max Howell is unjustifiab…

Most Googler SWEs have Mac laptops, not linux or windows laptops. But only a fraction of them use brew to install additional software. I'd love to interview the creator of homebrew. There are so many dependency and reliabiltiy questions that it's clear brew doesn't handle well (same criticism of CPAN, and pip to some degree) in terms of performance or correctness that you could just talk for an hour about graph probl…

How does Google develop software?

Someone told me they did all their development in the cloud and you aren't allowed to check out software locally? Does that mean they just use their macs as thin terminals? But what's running in the cloud for development then? Linux X desktops, or do you edit in a browser, or do you develop entirely in a console over SSH?

Nobody seems to talk about the developer experience at Google that I've seen, despite how much they talk about how they do operations and site reliability.

Re: Data structures and algorithms I actually used while working at tech companies

#360
post #351
post #345

Earlier quoted context omitted.

For a company whose main claim-to-fame is indexing the web (rather than mirroring it in their databases), Google sure doesn't seem to understand that CS learning is done by mentally indexing textbooks (rather than mirroring them in your brain.)

That may be true. But then why hire someone with just look-up skills before hiring someone who really tries, and enjoys the challenge? I'm interviewing engineers frequently and although I agree that the question asked by GP is maybe not the best it still gives the signal if someone is willing to power through a problem with minimal guidance and/or ambiguous constraints. Something I'm willing to find out at the peril…

> why hire someone with just look-up skills before hiring someone who really tries, and enjoys the challenge

This attitude will keep you from hiring someone who will just "do the right thing," which is to look up stuff that can be looked up, and also persevere when an off-the-shelf solution won't be sufficient. Plenty of engineers will spend time trying to reinvent the wheel when it is totally unncesssary.

Post reply on HN