r/programming • • Mar 29 '21

Why Do Interviewers Ask Linked List Questions?

https://www.hillelwayne.com/post/linked-lists/
1.1k Upvotes

668 comments sorted by

1.1k

u/Doctor-Dapper Mar 29 '21

A lot of the “script jocks” who started programming by copying JavaScript snippets into their web pages and went on to learn Perl never learned about pointers

Even in 2006, web devs were getting shit on by C programmers

338

u/tuxedo25 Mar 29 '21

Man that knife cuts so close to the heart. I started programming in the late 90s by copying javascript snippets and then I learned perl. Then I went to college and graduated with a CS degree in 2005.

222

u/Psypriest Mar 29 '21 edited Mar 29 '21

But did you learn about pointers?

173

u/tuxedo25 Mar 30 '21

I did! And despite all the fundamentals I've learned, I'm still a script jock at heart.

→ More replies (2)
→ More replies (34)

17

u/[deleted] Mar 30 '21

Almost the same story here , but graduated a year later.

Ripping javascript from other geocities sites to get cool mouse over effects or dynamic text :)

→ More replies (1)

71

u/flukus Mar 30 '21

Even if you're working in JavaScript or perl you should still know what a reference is and a linked list just requires knowing the absolute basics about references and data structures, there's no pointer arithmetic.

182

u/Seltzer100 Mar 30 '21 edited Sep 05 '25

racial caption plants act upbeat cautious fearless abundant rob squeeze

This post was mass deleted and anonymized with Redact

9

u/psycoee Mar 30 '21

The sheer breadth of constantly changing shite you have to keep up with is ridiculous in the web world.

I don't think anyone claims it's easy to be good at it. I guess to me, it's more of a skilled trade than a science -- the valuable stuff is the practical knowledge and skills, not the kind of theory that gets published in academic journals. Whereas, say, developing numerical solvers or AI algorithms is kind of the opposite, where practical considerations are secondary. CS academicians obviously value theory over practice, so they don't consider this stuff "real CS". Actual, working developers understand that there is far more to delivering a product than being really good at theory, so they value that aspect more.

→ More replies (1)
→ More replies (34)

106

u/ease78 Mar 29 '21 edited Mar 29 '21

God C programmers are the most contentious. They love to bolster bluster about their C89 vs C99 gotcha’s. They’re the most pedantic and the best usually😕

181

u/Doctor-Dapper Mar 29 '21 edited Mar 29 '21

Everytime I see someone being pretentious about pointers or memory management I just remember that they have nothing on people writing the compilers and assembly language. And those people have nothing on the engineers designing microprocessor architecture.

It all boils down to "my language is less abstract than yours. That makes me smarter than you"

Although to be fair, those engineers at Intel/Arm/Qualcomm are significantly smarter than me.

152

u/Miner_Guyer Mar 29 '21

That's why I stopped programming years ago and focused entirely on Turing machines and lambda calculus.

→ More replies (1)

88

u/kbielefe Mar 29 '21

I started my career in low level. The main reason I don't think "less abstract == smarter" is on average those programmers are terrible at creating appropriate abstractions. Decades later and people are still reimplementing linked lists over and over, and making frequent mistakes doing it. I saw an O(n6) linked list traversal once, spread over several files. Low level programming should be much less low level by now.

→ More replies (26)

28

u/SanityInAnarchy Mar 30 '21

No, you get it both ways. Try admitting you sometimes write JavaScript or Python to a Haskell or Scala fan, and you might get "My language is more abstract than yours, and therefore I am smarter than you."

→ More replies (11)
→ More replies (21)

25

u/spook327 Mar 30 '21

tMy absolute favorite thing about C programmers is how any time you ask a question, they'll say "go check the standard." ISO charges 198 francs for a PDF copy -- about $210 USD. Thanks, dickbrain.

34

u/ease78 Mar 30 '21

Buy the C standard for $210

oh that’s undefined behavior

→ More replies (1)
→ More replies (3)

6

u/[deleted] Mar 30 '21

You have to be "pedantic" with language that will shoot you at slightest mistake. Especially years ago where complilers weren't really complaining about things they should be complaining.

→ More replies (13)
→ More replies (12)

9

u/TurncoatTony Mar 29 '21

I never copied javascript snippets. I did a lot of copying but copy/pasting code never felt right when I started(That and way back in the early 90s we didn't have stackoverflow).

However, I'm glad I went from that to C and not Perl. :p I learned about pointers and that alone has landed me jobs.

6

u/slykethephoxenix Mar 30 '21

Could be worse. Could've started in VB6 like 13yr old me.

→ More replies (3)

12

u/[deleted] Mar 30 '21

This is why in uni they start you with plain old C. Not C++, bare bones C, until you master variable types, statements, conditions, loops, pointers, strings etc. Then if you pass those classes you are being taught object orientated programming for the first time. I spent an entire semester writing C scripts before I was taught what HTML is and what is called "a class" in Java.

14

u/wutcnbrowndo4u Mar 30 '21

My university (Berkeley) did exactly the opposite: the first three courses were respectively in Scheme (functional), Java (OO), and C.

→ More replies (3)

8

u/[deleted] Mar 30 '21

This is why in uni they start you with plain old C

This is not true. Lots of universities are moving to Python. Mine started with Java.

24

u/PortalGunFun Mar 30 '21

At my university they start you with basic programming and text parsing with Python, then teach you OOP with Java, before teaching data structures in C++, then computer architecture in C/Assembly

→ More replies (2)

5

u/Muoniurn Mar 30 '21

I think C is a terrible language from an educational point of view. You basically get no feedback on whether your code is correct, valgrind is usually not taught along with it, and even with that you can basically have to run each possible state of an app to be reasonably sure it is somewhat correct — and a grade on a work with even a good feedback is absolutely not similar to the instant feedback one gets from higher level languages. I pretty much believe it makes most students that didn’t already know how to program become worse as a matter.

At the opposite end of the spectrum, Python is also terrible imo as a first language from an educational pov — it is way too relaxed, duck typing doesn’t help in the beginning and you get basically no feel whatsoever on the algorithmic complexity of the code. Also, no compile time, no instant feedback.

I am definitely biased because I’m a fanboy, but even if you dislike it in the usual context, Java really strikes a great balance imo, and is just a great starting point. You get instant feedback by the compiler on many things (which I can’t stress how important is), and frankly, pointer arithmetics is not that hard as a concept — I think one can easily ascend/descend to higher/lower level languages from there.

→ More replies (23)
→ More replies (19)

216

u/librik Mar 29 '21

This research is a classic example of looking for your keys under the street light.

Usenet it is! The Internet Archive has a dump of 2,000 net.jobs posts between 82 and 86.

a whole lot of people are hiring for Unix and C programmers. 1 in 6 posts were for C and almost half of them mention Unix. This is a little more impressive when you realize 1) this was all jobs, not just “low-level” ones, and 2) Unix was competing with many other OSes at the time.

So, to summarize the theory: in the early 80’s, C programmers were in high demand.

Usenet was a Unix-specific discussion forum system, at a time when most big computer OSes were DEC and IBM. Usenet was based on software called UUCP, which stands for Unix-to-Unix Copy Program. The name "Usenet" comes from USENIX, a Unix user's group that was going to manage the network (but nobody ever did). IBM systems had BITNET instead.

So by searching on net.jobs, the author was really looking at the Unix world's hiring classified ads. That's why there was so much focus on making sure applicants knew Unix & C.

285

u/chx_ Mar 29 '21

Every time this topic comes up I feel obligated to link to Honeycomb's process: https://www.honeycomb.io/blog/observations-on-the-enterprise-of-hiring/ while there is no silver bullet this is certainly one of the best processes I've ever heard of.

117

u/4_teh_lulz Mar 29 '21

This is effectively how we hire as well - a short take home that is then code reviewed by the team. The candidate is then brought in to discuss their work with the reviewer.

193

u/trustMeImDoge Mar 29 '21

I have a love hate relationship with take homes. Done right they can give a lot of good signal, but they can also be done very poorly as well and just be bad times for everyone.

I did one once where I was told to use what ever language I was comfortable with. I had spent the last five years writing clojure so I picked that, and even confirmed with my contact at the company that it was okay to use, since lisps aren’t all that common. My review interview was then 45 minutes of me being grilled about what I was trying to do by picking such an esoteric language. I didn’t get the job, not that I would have accepted it after that treatment.

100

u/flukus Mar 30 '21

I don't mind take homes that are simple tests, but I've had some really annoying take homes like "build us a simple website with x" that has to be up to "commercial standard". These take way longer than they should because you're setting up authentication, DI, unit tests, etc and most of that is just googling shit I haven't had to do or think about for ages.

→ More replies (14)

36

u/pysouth Mar 30 '21

I like take homes when done well. My rules for take homes unless I was really really desperate:

  • under an hour to complete

  • no “build our app for free” bullshit

  • no repeat work e.g. do a take home and then do another coding challenge on site. I’ll happily discuss my work but I’m not gonna do another coding challenge if I spent an hour at home doing one

I would make an exception if it was like my dream job or something, obviously.

→ More replies (2)

67

u/[deleted] Mar 29 '21

Well it kind of worked then. Interviews should be as much for the interviewees to work out if they'd actually want to work in the environment.

→ More replies (1)
→ More replies (17)

74

u/butt_fun Mar 29 '21 edited Mar 29 '21

Regardless of efficacy, it's my opinion that these offline development interviews are disrespectful of the candidate's time. I've personally turned down more than a few interviews in this format because it signals to me that the company doesn't value my free time

When I'm interviewing, it's generally for more than one company, and it's generally while I'm already working full time at my day job. I'd rather do a dozen interviews that don't require any work outside the scheduled start and end times (even with all the shortcomings of the whiteboard) than spend three hours a night taking on a different company's coding challenges. It just wouldn't be sustainable if the entire industry did this

Edit: word choice

7

u/textredditor Mar 30 '21

The interview process needs a shake up. Getting a job is one thing. Getting one you love and keep for years is another thing altogether. I welcome a process where I get to take my time. Here’s a wild idea, treat the interview process less like a speed date, and more like a series of dates.

33

u/flerchin Mar 29 '21

3 hours is less than a full day on-site? Isn't that more respectful of our time?

→ More replies (6)

22

u/hippydipster Mar 29 '21

You wouldn't believe how much time is wasted going the other way though, by the fact that people who can't program for shit are wasting your time by making BS resumes, and the only way we can tell for sure is by asking people to write some code.

→ More replies (8)

23

u/Fairwhetherfriend Mar 29 '21

I'd rather do a dozen interviews that don't require any work outside the scheduled start and end times (even with all the shortcomings of the whiteboard) than spend three hours a night taking on a different company's coding challenges. It just wouldn't be sustainable if the entire industry did this

Is it really more sustainable to take the morning off work a dozen times to take interviews during working hours? I would much rather spend a couple of hours on an effective interview that I can do on my schedule over having to book time off work for an interview that is likely to go a bad job of actually showing my skill set anyway. I'm not even convinced that it actually takes more time to do - an hour interview can often end up costing way more than an hour all-told, between the time spent getting myself ready in the morning to look extra nice and professional, the commute, having to arrive early, etc etc. If you add on any prep work for the interview, it blows most code challenges out of the water completely. And if a company has chosen to demand a code challenge that's unusually long... well, then I would consider declining the interview due to disrespect of time. But I don't really buy that the typical coding challenge is actually that much longer than a normal interview is.

→ More replies (10)
→ More replies (3)

16

u/catch-a-stream Mar 29 '21

So... what is the actual interview process there? Some of the other comments imply it's some sort of take home test? If so, that has been tried multiple times in the past, and it doesn't really work... it's way too easy to cheat, and it's too time consuming for candidates so the only people who would actually do it are people who are having trouble interviewing anywhere else (or cheats, or both)... the end result is that the pool of candidates won't have strong candidates to begin with.

Or is it something entirely different? The article isn't super clear beyond the platitudes.

Genuine question btw - the interview process is pretty bad, but none of the alternatives I've seen so far work any better, so really hoping to learn something here.

23

u/Democretes Mar 29 '21

It's a take home test that you have to explain your answers in person. I think it's supposed to help weed out people who are bad with communication.

I suppose it would also prevent cheaters from getting anywhere because it would be blatantly obvious that you cheated if you couldn't explain your code properly.

→ More replies (15)

16

u/Fairwhetherfriend Mar 30 '21

it's way too easy to cheat

If someone can cheat on your code challenge, that's a problem with the challenge. You're not supposed to be asking questions intended to test the memorization skills of the potential employee. Don't ask them to name 3 different sorting algorithms or anything like that. Give them a simplified version of a real problem to solve - a little less "show me how to remove an item from a linked list" and a little more "you're making a video game and want to build a function to roll for loot from the attached loot table. write some code that would do that, list your assumptions, and explain why you took the approach you did."

Sure, yes, someone could still cheat if they just had another person literally write the code for them. But it doesn't matter because the in-person interview should involve at least a few questions asking them to explain certain choices about their code, which they will not be able to answer comfortably if they didn't write it in the first place.

→ More replies (1)
→ More replies (3)

207

u/tinbuddychrist Mar 29 '21

I've seen "remove an item from a doubly-linked list" used as an interview question, for very non-mysterious reasons:

First, it's a question that basically anybody should understand.

Second, that it's almost entirely made up of edge cases, so it tests their ability to come up with all relevant scenarios. Most people miss at least one.

78

u/Wildercard Mar 29 '21

Second, that it's almost entirely made up of edge cases,

Most people miss at least one.

Happy case is an item somewhere in the middle of the list, edge cases being first or last node, empty list, one element list?

48

u/kurtms Mar 29 '21

Or element isn't in list

8

u/YumiYumiYumi Mar 30 '21

Alternatively, implement the list with always-present sentinel start/end nodes, then you don't have to worry about the edge cases.

→ More replies (1)
→ More replies (8)

33

u/wipfom Mar 29 '21

The legibility and code quality can differ widely between successful solutions. This can also lead to interesting conversations on maintainability with an interview candidate.

16

u/mycall Mar 30 '21

In the mid 80s, I overused doubly-linked lists. They were my go to for in-memory records from block files (aka poor mans database).

7

u/flukus Mar 30 '21

In the 80s the bus speed and CPU speed were the same, a perfectly sensible decision then wouldn't be one now

28

u/sophacles Mar 30 '21

Re 1.: I think a lot of people don't realize that there are a people who can bullshit through a phone screen but can't actually program, even simple things.

The simple algorithm test (Or the pair-coding equivalent I've seen work well) weeds out those folks.

14

u/percykins Mar 30 '21

Yup. Hell, I used to phone screen with the question “How would you write something that prints out a multiplication table?” You’d be amazed how many people fail that.

→ More replies (12)
→ More replies (4)

30

u/lovestheasianladies Mar 30 '21

No, it tests if they've already done it before.

→ More replies (1)

92

u/anengineerandacat Mar 29 '21

Interview questions are hard and unlike when you hire a plumber it's difficult to warranty the work so people come up with all sorts of ways to instill "trust" into a candidate that they can perform the job.

I don't work at a place that has Google level software engineering problems, we just need individuals who can make a website with our organizations selected technical stack and or be willing to follow along with the organizations goals.

This means the toughest an interview questions gets is about as bad as making a routine that can determine if a string is a palindrome or not (we generally don't ask candidates to make new collection types or things an STL does out of the box because in our world we create business solutions using technology not new technologies).

I need to know whether a candidate can reliably code (we even dumb it down to where the candidate can select from a range of languages; Java / C# / Python / TypeScript) and whether they are capable of addressing a problem along with being able to explain their solution and how they conduct themselves.

The Linked List question is interesting because it shows understanding of a few concepts (if the question wasn't text-book common).

  • Does the candidate know how to create multiple data structures and utilize them together to create something new?

  • Do they know how to use conditionals?

  • Loops?

  • Error management (try / catch / throw)

  • Is the code produced legible?

However I prefer to have my candidates ask me questions vs just complete a homework assignment, I love seeing how a candidate is able to identify and address a new problem; something the LL question doesn't generally do (unless they don't know what a linked list is, which I doubt many CS majors today don't know but I find many graduates don't know what a palindrome is).

27

u/creativemind11 Mar 29 '21

This was how my current company did it and still does, with the same assignment from 4 years ago. No coding, no writing, just talk. They present a design and ask the applicant to explain how he would take this in broad terms.

Then they probe him a bit with some challenges. In the end even if you completely fail this part it shows whether the applicant admits his hers areas to improve on and also what they do know. Learning new languages is easy, learning how to think logically and in software terms is a bit harder. But most of all showing you were enthusiastic and had a passion for this field with some half-baked snippets of side projects usually resulted in good to decent coworkers.

6

u/VoldemortsHorcrux Mar 30 '21

I like that so much more. Generic interview questions only tell you if a person studied before the interview or not. As a developer you will always have the internet to research little things. I use Google so many times a day as a developer it really should just come down to: are you passionate, are you a quick learner, and how will you work with others. If you can complete a linked list question, great. You practiced the night before like anyone else would do

→ More replies (1)

28

u/odnish Mar 29 '21

For the palindrome question:

  • is it a case sensitive or case insensitive comparison? E.g. 'Radar'

  • what about unicode normalisation?

  • what about graphemes made of multiple code points? E.g. '🇺🇦🇦🇺' or '🇨🇦🇨🇦'

→ More replies (16)
→ More replies (2)

84

u/WhyYouLetRomneyWin Mar 29 '21

Interview argument #4067... Here we go again...

Basically I see 2 camps: are you testing a real skill, or testing a toy skill and extrapolating to 'if they cannot do basic skill they probably cannot do real stuff'?

The former argues that link lists are an uncommon DS. The latter usually doesnt dispute that, but insists that using linked lists demonstrates fundamental skills (its not about the ljnked list per se, but ability to manage pointers, consider edge cases, write tests, etc.)

I feel like the groyps talk past each other too much.

8

u/FalseRegister Mar 30 '21

So what's the correct way? :)

→ More replies (3)

36

u/de__R Mar 29 '21

one other thing is interview ergonomics - linked lists in C require a couple of minutes of work, so a simple list question wouldn’t feel too short nor too long. Hash tables or array backed lists take a little too long to implement, and very simple things like strings or other dumb arrays are too easy.

As language ergonomics change, though, the kinds of questions people ask change as well. The joke about “When in doubt, use a hash table” is true in part because popular languages these days give you easy hash tables. But you could go further, metaprogramming constructs are getting more popular so things like dynamic programming (itself only a slight twist on “use a hash table”) could become the dominant question paradigm. Or stuff that relies on algorithms for immutable variables and functional programming. And so on.

14

u/s73v3r Mar 29 '21

one other thing is interview ergonomics - linked lists in C require a couple of minutes of work, so a simple list question wouldn’t feel too short nor too long

I would wager that the vast majority of interviews are not being conducted in C/C++.

→ More replies (3)

131

u/[deleted] Mar 29 '21

In my experience most people doing the interviews just pull the questions from the internet and since linked lists have been the defacto interview question for 30+ years, you're more likely to get asked them.

→ More replies (35)

59

u/bluefootedpig Mar 29 '21

One of my managers said he just had a simple test to make sure you knew at least something.

They had a new project, winforms already up. Said to make a dropdown that contained a list (provided to me) and sorted the list.

That was it. If you can know how to inject into an object, and a basic sort... that was enough for him. He said he has weeded out about 10% of candidates that make it that far. Often it is their friend that did the phone interview, then they went in person.

I honestly think the best way to gauge is to talk to the person about pain points of the industry. People with experience know the pain points. We all have our things we wish were better. So often jokes about regex, or java being so much more restrictive than C# when it comes to handling errors. How popular python is becoming and how integrating it into existing systems, etc...

If you and them can both keep a conversation about our industry going, I trust you know what you are talking about.

13

u/Condex Mar 29 '21

Pain points honestly sounds like a great way to gauge skill. Not foolproof but I've been involved with several interviews where the question was pretty effective.

Using it as an interviewee also seems like a good idea. If after asking about a company's pain points, everyone clams up and trys to not look at the most senior person in the room then maybe you should keep looking.

36

u/tuxedo25 Mar 29 '21

I used to think that was true. But you pass a lot of people who washed out of tech and have spent a few years as product managers or something. All talk no skills.

→ More replies (4)

23

u/orsikbattlehammer Mar 29 '21 edited Mar 30 '21

I’m about to graduate with a CS bachelors and I genuinely don’t know if I could “inject into an object” I have no idea what that means. I feel like I’m the smartest guy in class but when y’all talk about interviews on Reddit I feel like I’m a 80 yo grandma who can’t use the remote. Jesus I’m scared.

Edit: y’all have made me a lot less scared lol, thank you.

39

u/dark_mode_everything Mar 29 '21

Don't worry. No one learns that in uni. Everyone spends their first year or so learning how to use the remote. Actually, you'd still be learning after decades. Word of advice though, don't think that you're the smartest person in the room. There's always someone smarter.

→ More replies (1)

21

u/[deleted] Mar 29 '21 edited Mar 29 '21

I'm a developer with several years experience and I have very little idea what they mean either, so I wouldn't worry about it too much.

I assume they're talking about dependency injection but I know nothing about winforms so I could be off.

I don't know how much of OOP Design Patterns they really teach in the average CS curriculum. It's not something I would interview a fresh grad on personally.

16

u/hippydipster Mar 29 '21

I'm with you. People talk with very weird jargon sometimes. I hear "inject into an object", and I'm just thinking "oh god, the poor object, don't do that!".

"I meant call a method with the list as an argument".

"Oh, thanks for talking like someone faking being a developer!"

12

u/Zofren Mar 29 '21

He means dependency injection (I think). Depending on the context it's kind of a poor question. DI isn't a good pattern in every language so it's understandable not everyone would be familiar with it.

→ More replies (1)

3

u/astrange Mar 30 '21

I for one think he made that word up.

3

u/lnkprk114 Mar 30 '21

That's just because you haven't developed any windows applications (which is what I'm assuming the OP is talking about). Don't feel scared, no one expects you to have a lot of domain specific knowledge like that.

→ More replies (4)

8

u/Wildercard Mar 29 '21

If you and them can both keep a conversation about our industry going, I trust you know what you are talking about.

Man you would not believe how much info you can pull just by following the memes.

5

u/bluefootedpig Mar 30 '21

There is a lot, but I find unless you have knowledge, you can know the meme but you won't understand why. And it is great to use that as a way to be, "when did you run into that?" and get more history from the person as to problems they had.

Think about it, it isn't much different than the question, "what is a problem you solved and how did you solve it?"... "what is a pain point in programming that bothers you, and when did you encounter it?"

→ More replies (2)

2

u/Repulsive-Philosophy Mar 30 '21

Honest question: how do I inject to an object in winforms?

26

u/Eluvatar_the_second Mar 30 '21

As an application developer I've never had a use case for a linked list. Maybe there's a case where it would have performed better than an array, would the difference have been noticable. No.

The only reason I ever learned about them was because of an interview.

39

u/turniphat Mar 30 '21

Link lists have fallen out of fashion because they have terrible cache performance. There are very few algorithms where insert performance matters enough to give up O(1) random access. And if you have to allocate memory to insert, that is already bad for performance so why optimize the actual insert.

These days with huge amounts of memory, just allocate a big array. They still have their place in operating systems and embedded systems.

5

u/FalseRegister Mar 30 '21

Some languages use linked lists to implement queues and stacks. Having O(1) for insertion and removal makes it. I'd argue that it's much more used than OS and embedded systems, just not directly.

→ More replies (2)

11

u/rlbond86 Mar 30 '21

I do a pot of embedded programming and they can be really useful there, especially intrusive linked lists, because you don't have to allocate memory.

2

u/PstScrpt Mar 30 '21

They never perform better than the array-backed lists that most modern languages have built in, but they're occasionally a natural fit for your problem. Usually when what you need to do is already going to be recursive.

10

u/ozyx7 Mar 30 '21 edited Mar 30 '21

So why do interviewers like to ask linked list questions? If you ask people, you usually get one of two answers:

  1. “It tests CS fundamentals.”

  2. “It tests reasoning through a new problem.”

These answers are contradictory

I don't think they're necessarily contradictory. The "fundamental" part is reasoning about and dealing with pointers, which are a necessary building block for building data structures. The "new problem" part is dealing with a pointer problem that interview candidates probably haven't directly done before (e.g. reversing a singly-linked list).

Rampart Speculation

Is that supposed to be "rampant", or is there some pun I'm not getting?

It’s a test of if you’ve programmed C.

(Or Pascal.)

What’s especially interesting about purpose is it’s the complete opposite of the purposes we think of today. Companies weren’t testing for theoretical CS knowledge, they were testing for practical experience with pointers.

Obviously? When I've asked linked list questions during interviews over the past ~15 years, it was explicitly for the purpose of testing experience with pointers. I disagree that it's a "complete opposite of the purposes we think of today". It was to test an understanding of pointers (which is pretty language-agnostic; almost all languages have the concept of a pointer/reference in some form), not about specific C experience.

Anecdotally, I asked a linked list question as part of a phone screen. Inability to reason about pointers helped to filter out a large number of candidates.

6

u/ellicottvilleny Mar 29 '21

Tradition. (Cue the music from Fiddler on the Roof)

29

u/NoMoreNicksLeft Mar 29 '21

If 1981 ever returns, it may be necessary for programmers to re-implement those with their c compiler for which the only documentation is a dog-eared 4-inch thick book for their cutting edge AS400.

You don't want to hire people who will be useless when the inevitable chrono-dynamic inversion happens.

5

u/dreamCrush Mar 30 '21

Sure it's not 1981 today but who knows what the future could bring

→ More replies (1)

3

u/AmorphousCorpus Mar 30 '21

or, you know, just show that you can reason about difficult problems on the spot and write neat code to go with it

→ More replies (1)
→ More replies (2)

5

u/PL_Design Mar 30 '21

I used to run booths at job fairs for my old employer. I found the best questions to ask to see if someone's resume is worth considering were:

  1. What's the difference between an array and a linked list?

  2. Can you tell me how a hashmap works?

  3. Tell me about the projects you've worked on.

The linked list question was just a heuristic filter so I could make sure I had a chance to speak to everyone coming to my booth. "If this guy doesn't know what a linked list is, then chances are he doesn't know more complicated things that he needs to know. Let's move on to the next person."

The hashmap question was to test either that someone cared enough to learn how his tools work, or to see if he could reason through how a hashmap might work. If candidates needed help reasoning about hashmaps, I'd walk them through how hashmaps work, and as long as they understood what I was saying I didn't count it against them.

If someone failed the first question I'd still ask them the third question so they'd have a chance to tell me what skills they have. I had one dude who did not care about programming at all, but he absolutely loved databases, so I passed on his resume because that is a skill we cared about. For people who did well on the first two questions asking them about their projects was a good way to figure out what projects would fit them best.

25

u/maestro2005 Mar 29 '21

Linked list questions are sorta tricky, but should ultimately be easy for anyone comfortable with pointers/recursion. Joel Spolsky may have written that article a long time ago, but the fundamentals of programming haven't changed. You really don't want to hire anyone, even for an intro-level position, who can't grok how to reverse a linked list.

"But when do you ever have to write that in real life?" is a stupid counter-argument. You want people who are actually good at programming, not people who can just barely wrap their heads around day-to-day tasks.

32

u/Supadoplex Mar 29 '21 edited Mar 29 '21

Linked list ... pointers/recursion.

A thing about linked lists is that you should never use recursion to implement algorithms with them in practice - in languages such as Python, Java, C, C++, C#, JavaScript (until ES2015), Rust, Go, which do not eliminate tail recursion (or at least aren't guaranteed to do so) and thus will (may) overflow the stack if the list is moderately long.

8

u/justin-8 Mar 30 '21

See, I would take that as a really big plus if you answered the question that way in an interview. Showing in-depth knowledge of why you don't want to do something, and language specific implementation details that can be a sharp edge show that you know the language quite well, as opposed to someone that just naively suggests how to use a linked list in Python or whatever.

7

u/rabuf Mar 30 '21

It's near trivial to convert the recursive expression to iterative in this case. It's almost always just moving from a recursive form like:

def f(node):
  if node == null:
    return null // or signal an error
  if pred(node):
    return g(node)
  return f(node.next)

to:

def f(node):
  while(node != null):
    if pred(node):
      return g(node)
    node = node.next // this trips up a surprising number of people
  return null // or signal an error

But it's still a recursive form over the data structure, even if it's not recursive code. This is actually one of the interesting things about linked lists. They're about as trivial as you can get for a self-referential data structure and that can actually indicate a lot about a person's understanding of complex data structures. If you can't do something with a linked list (iterative or recursive code, it still possesses a recursive form) you will probably struggle with any kind of a tree or graph structure (which are much more common in practice, even non-obvious instances of such structures where they're hidden inside a database where entries contain references to other entries or with maps to map to maps).

→ More replies (11)

11

u/FyreWulff Mar 30 '21

because programming interviewing is one of the earliest instances of cargo culting in the industry

4

u/[deleted] Mar 30 '21

While I see the value of asking these sorts of questions because it is just basic problem solving. Rarely do interviews ask if or how you can write clean code and solutions.

4

u/PstScrpt Mar 30 '21

"Fog Creek used a mix of VBA and C#, neither of which require you to write your own LL algorithms."

If you wanted a linked list in VBA (classic VB), you did have to write it. And it wasn't such a bad idea when the only built in data structure was the array.

I used to write binary search trees in classic VB all the time, too. Now I'd just use a dictionary.

11

u/-dag- Mar 30 '21

True story. I once had a interviewer ask me to implement a linked list. I was already super annoyed at other interviewers who had asked similarly inane questions and the conversation went something like this:

"Write me a linked list."

"Uh, ok, what should it hold? An int?"

"Sure."

std::list<int> x;

I got the job offer.

I rejected it.

6

u/is_this_programming Mar 30 '21

That's not what I would call writing a linked list.

3

u/-dag- Mar 30 '21

That's the point.

7

u/maest Mar 30 '21

Sounds like they dodged a bullet there

→ More replies (1)
→ More replies (2)

3

u/Quabouter Mar 30 '21

I've been interviewing candidates for a long time now, and I settled on an stupidly simple but effective approach to interviewing questions: I pick a hard problem we had to solve in real life, and adapt it into an interview question. This is directly testing the candidates ability to solve actual problems we're solving in the company. Candidates tend to like this as well, as they'll get a glimpse of what they would be doing when hired, and because it's usually much closer to their day-to-day work than the typical CS interview questions.

→ More replies (1)

4

u/zhivago Mar 30 '21

The linked list is pretty much the simplest recursive data structure.

For some reason, weak programmers often have trouble with recursion.

(Which is odd, since at its core, it is just about breaking off part of a large problem to make the large problem a bit smaller, until you get down to pieces you can handle without breaking them down any more)

In interviews, I try to make sure that recursion is covered.

Recursive data structures are similar, and you can look into lazy data structures of infinite size, as a follow on.

2

u/yudlejoza Mar 30 '21

... “script jocks” who started programming by copying JavaScript snippets into their web pages ...

I prefer "java-script-kiddies" (some of them now morphed into type-script-kiddies).

2

u/RICHUNCLEPENNYBAGS Mar 30 '21

These answers are contradictory: if you want to know if someone knows CS fundamentals, you don’t want to give them a problem they can trick their way through, and if you want to test reasoning ability, you don’t want to give a problem that they’ve already seen in CS.

Well, I don't think so. Most of the task of programming is solving tiny problems that you know how to solve trivially using the building blocks you have, then doing that again, and again, until you've achieved the main, overarching task.

2

u/NoLemurs Mar 30 '21

There are good arguments to be had about how and why we do what we do when we interview. This article doesn't make any of them.

The article more or less assumes the conclusion that linked lists are used for historical reasons that don't make sense any more, fails to find any real evidence for the claim, and then concludes "that's good enough for me."

And still, the article has ~1000 upvotes.

I know people hate interviews, and love to agree with anything that argues they don't work, but come on!

2

u/General_Mayhem Mar 30 '21

Oi. So many bad assumptions. I would not hire this person, based purely on this post.

Does the author think that C is the only language in which a linked list can be implemented? If you write Java, or Python, or Javascript, or really any mainstream language other than maybe Haskell, and you don't understand the concept of a pointer, you're going to have a real bad time.

→ More replies (4)

4

u/reini_urban Mar 29 '21

In my extensive experience linked lists care actually extremely hard to implement, compared to deque, vector, trees, heaps or maps/hashtables. Well hashtables are the second trick question, you can be sure that nobody knows them properly. But everybody thinks linked lists are too trivial to worry about.

I just implemented all STL algorithms for forward_list, and it was extremely tricky and special. reverse is one of the easiest, but splice, shuffle or sort are very tricky. The STL even skipped shuffle because too difficult, and they implemented iter_swap only by value swap, whilst you really need to do it by pointer relinking. The STL is also not cycle safe, and has no cycle check nor a cycle-safe length/size function.

So even by asking about the innocent length function you won't hear about Floyd and fast-slow iteration. But you should.

Doubly linked lists are actually easier than single linked lists.

→ More replies (3)

3

u/Southy__ Mar 30 '21

I have recently totally changed my whole interview process.

I start from the assumption that whatever is on the CV is true, that they can write software as well as they say they can. This is a big shift away from the 'prove you can write code before we will speak to you' attitude of most tech companies.

In the interview I get the candidate to talk through their past jobs, what they are working on right now, ask questions as they go about technical aspects of their work.

Then tell them about our work, what tech we are using and the problems we are solving.

The good candidates are super engaged with this process and have lots to talk about and lots of questions about what they would be doing on the job.

The bad candidates are very easily spotted as they can't even talk for 10 minutes about what they are actually working on right now.

So far it's gone really well, 4 hires using this method and they have all been great, and lots of positive comments about the lack of a pointless test that checks if you can remember stuff that you would normally just search the web for.

→ More replies (1)

4

u/rabid_briefcase Mar 29 '21

Interesting article, and I suspect it depends tremendously on the job being done. Someone hired for Angular and Javascript development of a web page will be radically different from server work, which will be different again from systems-style work.

Further, that the article is talking about old Prolog, Lisp, Pascal and Smalltalk for job interviews, so there's that.

8

u/fishling Mar 29 '21

Further, that the article is talking about old Prolog, Lisp, Pascal and Smalltalk for job interviews, so there's that.

Did you get that this was because they were analyzing old postings to find out about the origin of the linked list interview question? Your phrasing seems like you are trying to dismiss the article as not relevant because it is out-of-date, which kind of implies you missed the point of what the author was doing.

5

u/CypherBob Mar 30 '21

Because they have absolutely no clue how to determine someone's ability to write good code.

Very VERY few jobs require you to know how to create linked lists, invert binary trees, roll your own sorting algorithm, or implement an existing one.

2

u/[deleted] Mar 30 '21

Just curious, what would you say most jobs include instead?

10

u/CypherBob Mar 30 '21

Understanding architecture, basic scalability, how to research solutions, how to evaluate libraries, writing sensible maintainable code, planning ahead, prioritizing, just for starters.

Give them a real problem and let them solve it using any resource they want, and compare what they come up with to your devs solution.

Have them walk through scaling an app up from proof of concept to 5k users.

Give them a common problem solvable with a library, and ask how they would research and determine the best one.

Anyone can memorize algorithms, but it takes experience to talk about this stuff intelligently.

→ More replies (1)
→ More replies (1)

3

u/Kinglink Mar 30 '21

“It tests CS fundamentals.”

“It tests reasoning through a new problem.”

These answers are contradictory:

What if I told you they aren't.

First off not every Linked List Question is the same. "How do you find out if a linked list is a loop" is not the same as "How do you invert a Binary tree?" Nor is it the same as "How do you remove a element from a linked list?"

But more than that, if it's a fundamental of the candidate, great you move on to more interesting and harder problems. If it's not, you dig in and start to work on the problem solving. Every candidate is different and the best way to interview them is work through a problem. Finding an interesting problem is far more challenging.

So people will say "Just use a problem that occurs in your job." First off explaining the problem could take half an hour, it also is probably something you can't talk about (I just got the job to supervise some interns. I can't talk to them about the specifics or even parts of the job until they are legit on-site. There's no way I could talk to an interview candidate about anything we do.)

While I appreciate the deep dive into the actual foundation, I continue to boggle at people who think every question has one specific usage and one specific situation, especially when it's a tier of questions such as "Linked list" questions. As if they can't be more than one version of that question.

2

u/emasculine Mar 29 '21

i wonder when the last time the higher level language users have used a linked list.

for (p = list, pp = &list; p; pp = &p, p = p->flink);

gad, i had to think about that. it's been years since I've written C, and i've used that incantation zillions of time in the past.

2

u/Edward_Morbius Mar 29 '21

Because it shows you actually understand very simple data structures.

2

u/[deleted] Mar 30 '21 edited Mar 30 '21

this is a tough love answer.

its because questions about linked lists test your knowledge. it might not be the ideal test, but it's effective.

linked lists are not advanced. they're actually a beginners concept in algorithms and data structures.

if you dont even know what a linked list is you dont know programming very well and that is a fact.

linked lists are not complicated... unless you have purposely avoided learning them which would be a shame.

people who claim they dont use linked lists in x years of coding are wrong. if you code every day, you use a linked list every day, and you probably dont even realize you're doing it.

people who claim that knowing how to make one by memory is not a useful skill are wrong. if you don't know your entry level DS/ALGS you are like a carpenter who refuses to use a carpenter's hammer.

→ More replies (1)

1

u/GayMakeAndModel Mar 30 '21

I don’t know. I don’t care. What I see is a dirth of people that can explain the difference between an inner join and an outer join or the difference between an inner join and a semi-join. Coherently...

Why the hell are so many developers utterly deficient when it comes to SQL? God forbid you ask them to understand what is an index.

All this shit plainly stated, why is it acceptable that developers cannot the understand a RDBMS? Seriously, what the actual fuck? Don’t understand locking and lock precedence? Get the fuck out of my development shop.

Edit: I had a bad day interviewing

2

u/[deleted] Mar 30 '21 edited Mar 30 '21

SQL is dull to many. You might find English dull, hence you write “dirth” when you intended “dearth”. Not to say you are a bad communicator because I understand exactly what you mean even when your spelling is only close. And most programmers get by just fine with a shaky, nodding acquaintance with SQL.

→ More replies (4)

1

u/8hob Oct 21 '24

I disagree that linked list is no longer relevant in testing a candidate's basic skills. Some people think that linked list questions are tricky, likely because they've implemented it the wrong way. For someone with decent programming skills and data structure knowledge, linked lists are pretty straightforward to implement if you add a the head/tail node: https://8hob.io/posts/simple-error-free-linked-list/

1

u/bentaro-rifferashi Mar 30 '21

Super interesting article. I think understanding linked lists and references is still relevant. Even if you work in a modern language like C# you’re still gonna get some unexpected results if you don’t understand what’s going on under the hood.

1

u/Informal_Swordfish89 Mar 30 '21

Linked lists are invaluable of you're working on C.

1

u/jbergens Mar 30 '21

My memories from being interviewed for a job in the mid 90's was that was not much technical questions at all. I came out of University and they probably mostly trusted that. There might have been a single page written test but it was easy. We probably spoke a bit about programming and tech but not that deep.

In a way it is more frustrating now. I have over 20 years of experience and still find jobs where they want me to do a toy take-home exercise to show that I can do programming.

2

u/-dag- Mar 30 '21 edited Mar 31 '21

Your experience matches mine. The degradation in interview quality is appalling. It's lazy interviewing. It used to be that interviews were about getting to know someone, seeing if their personality would be a good fit, etc. A fair amount of it was selling the candidate on the job. Now it's just a test, with all of the baggage testing has. Testing is inherently discriminatory, for one.

Interviews used to be respectful of the candidate's past work, whether in school or on the job. There are still companies doing good interviewing. But FAANG has ruined the process for too many people.

1

u/Snakehand Mar 30 '21

To filter out the RiiR crowd :-)

1

u/[deleted] Mar 30 '21

a list and its linked, what more do you want to know

1

u/sethamin Mar 30 '21

The entire premise of this article is wrong.

“It tests CS fundamentals.”

“It tests reasoning through a new problem.”

These are not contradictory because it's both. You want to find out if a candidate knows CS fundamentals AND you also want to see if they can apply those CS fundamentals to a real problem.

1

u/[deleted] Mar 30 '21

Because cargo-culting.

1

u/chidoOne707 Mar 31 '21

I learned a lot reading the comments from this post. Thanks.

1

u/urbanek2525 Mar 29 '21

Rampant Speculation

Rampant

Rampart

6

u/jackmon Mar 29 '21

What, you're not familiar with Rampart Speculation: The medieval practice of hypothesizing about castle ridges?

→ More replies (1)
→ More replies (1)

1

u/rediot Mar 29 '21

I ask this question just to understand the candidates level of skill with data structures. Generally anyone who can name a few GoF patterns I focus interview more on behaviors and experiences. If they miss on data structures I step down to generics, databases, etc.

1

u/Adadum Mar 29 '21
void push(node **const head, const value val) {
    node *const n = calloc(1, sizeof *n);
    assert( n != NULL && "list::push **** allocated node is NULL. ****" );
    n->value = val;
    if( *head==NULL ) {
        *head = n;
    } else {
        n->next = *head;
        *head = n;
    }
}

value pop(node **const head) {
    if( *head==NULL )
        return nil_value;
    const value ret = (*head)->value;
    node *rm = *head;
    *head = rm->next;
    free(rm); rm = NULL;
    return ret;
}

will code for food.

1

u/jldugger Mar 30 '21

Without reading the article: to filter out anyone who has ever thought 'I should use a linked list here.'

1

u/[deleted] Mar 30 '21

I have been a developer for ~8 years and I would walk out of an interview that has questions about linked lists unless the job actually involved building linked lists. I would tell them “If you want to play trivia games, find someone else. My work speaks for itself. You have my number if you change your mind.” ✌️

→ More replies (13)

1

u/skulgnome Mar 29 '21

An idiot can check the answer with reasonable confidence.

1

u/JazzRider Mar 30 '21

I would probably respond “Yes, I can work with pointers, but why?” In most modern Dev environments, there are dozens of different classes that implement dynamic memory.

→ More replies (1)

1

u/thebuccaneersden Mar 30 '21

Probably just to see what you were taught in CS. To be honest, I haven't had to code any type of linked list since forever, but I still think it's cool that I have that knowledge tucked away in memory from like 20 years ago just waiting to be applied somewhere. But, no, it's hardly practical knowledge these days for a lot of tech jobs (especially with dynamic languages), but it does score high on the "I'm a total nerd" scale if you do.

Also, I mean, the reality is that some programmers are cut from different cloth. Some are more interested in the computer science angle of things. Studying computers and programming languages and understanding how they work. And others are more pragmatic and view things as just tools to get stuff done.

I'm oddly in between. I know a lot of stuff and can happily teach others, but I'm just more interested in knowing the concepts rather than actually applying them.

-11

u/chucker23n Mar 29 '21

So why do interviewers like to ask linked list questions? If you ask people, you usually get one of two answers:

“It tests CS fundamentals.”
“It tests reasoning through a new problem.”

It’s an opportunity for the interviewer to feel superior.

21

u/sonstone Mar 29 '21

I think more about laziness than superiority

4

u/kjacks05 Mar 29 '21

This guy gets it

→ More replies (3)

7

u/lelanthran Mar 29 '21 edited Mar 30 '21

It’s an opportunity for the interviewer to feel superior.

I doubt that anyone asking about stuff that's taught, literally, in the first year of computer science, is doing so to feel superior.

2

u/hpp3 Mar 29 '21

Just like Fizz Buzz right?

2

u/chucker23n Mar 29 '21

Fizz Buzz is arguably an OK quick way to figure out if the candidate can write any code at all. Using the modulo operator at least has common modern uses, and even if you can’t immediately think of that, you can demonstrate understanding loops and conditions.

Implementing a linked list yourself (or any such data type) is almost never a practical scenario. Heck, if someone did that, it’d give me NIH vibes.

6

u/quadrilateraI Mar 29 '21

A linked list is a bare, generic version of a very common pattern. You're unlikely to implement a LinkedList class from scratch. You're far more likely to implement some implicit list/graph structure in your object dependencies that you need the same skills to traverse.

→ More replies (5)

6

u/barnabytheplumber Mar 29 '21 edited Mar 29 '21

I cannot wrap my head around the reasoning for point number two. I guarantee you as an interviewer, you are not coming across a talented candidate who has never seen a linked list problem before, but is able to reason his/her way through it. That's laughably absurd. If you happen to come across this person, who is able sight-unseen to reverse a binary tree on the spot just by reasoning it out, in a time limit, under pressure, you need to offer him/her a job immediately, and wonder how they fell through the cracks and managed to appear on your front door. Like dynamic programming? This style of reasoning didn't even exist for most of human history, people didn't just figure that out. If your junior candidate comes up with dynamic programming on the spot as a way to optimize the big O runtime of their algorithm, you might want to consider stepping aside and letting them be your boss.

The person who is successfully answering this problem is the person who has committed it to memory through rote memorization, and has repeated solving it over and over in a rote memorization type of way. It's possible that, by changing around the wording or throwing in a few trick details, you might completely throw one of these people off, and their ability to solve it goes out the window. That doesn't really seem like the makeup of a talented programming candidate to me. What does rote memorization have to do with debugging code, or building a feature or an entire project from start to finish, or design, or working as part of a large codebase? I'm completely baffled. I could see how memorizing syntax or features of a programming language or framework's API could be useful. How many of these positions legitimately require solid CS fundamentals? Choosing the right data structure can often be helpful to day-to-day programming. Although I feel like that can usually be achieved with a few rules of thumb. Not that I'm a super experienced programmer, but I'm rarely if ever writing or leveraging algorithms of any type.

5

u/quadrilateraI Mar 29 '21

Sorry, but reversing a binary tree is exactly the type of problem I'd expect someone to implement on the spot without preparation. It's about four lines of code. The style of reasoning should be intimately familiar to anyone applying to such a job, learning that way of thinking is the entire point of the field.

→ More replies (2)

4

u/Glacia Mar 29 '21

I guarantee you as an interviewer, you are not coming across a talented candidate who has never seen a linked list problem before, but is able to reason his way through it.

Huh? Linked list is a trivial datastructure, it's as simple as it gets.

6

u/barnabytheplumber Mar 29 '21

Right. A linked list is a pretty rudimentary data structure in academic settings, I think it's simple enough to wrap your head around them early on. Understanding how to traverse them, or how to mutate them (or reverse them) is another layer on top of that. I'm just saying that I think by asking this question, you're probably requiring some overhead of previous CS knowledge. I don't think it's realistic for interviewers to be expecting the possibility of their candidate not knowing what a linked list is, requiring a simple summarized explanation, and then it clicks and they're able to figure out how to reverse it, and then reason out what the O(n) and memory considerations are of that approach.

5

u/tuxedo25 Mar 29 '21

I don't think it's realistic for interviewers to be expecting the possibility of their candidate not knowing what a linked list is, requiring a simple summarized explanation, and then it clicks and they're able to figure out how to reverse it, and then reason out what the O(n) and memory considerations are of that approach.

Totally agree. It's a shibboleth. You either know it or you fail the interview. Nobody's gonna pick it up on the spot.

8

u/[deleted] Mar 29 '21

As much as I agree that current industry interview techniques are a bit ridiculous, I'd be pretty worried if a candidate didn't know what a linked list was or at-least, was unable to reason about it at all.

→ More replies (1)
→ More replies (1)

3

u/sysop073 Mar 29 '21

Saying this is an opportunity for you to feel superior to interviewers.

2

u/chucker23n Mar 29 '21

I’ve interviewed candidates before. I like to ask questions and pose challenges that are pertinent to the job.

0

u/[deleted] Mar 30 '21

[deleted]

4

u/[deleted] Mar 30 '21

You're missing the entire point of this post... how many companies need computer scientists, as opposed to just programmers? The answer is "very few", so why do so many ask (irrelevant) compsci questions?

The answer is that companies are (a) generally staffed with incompetents in the hiring department (b) love to pretend that they are doing difficult work, when actually they're just building yet another line-of-business application. Until this self-aggrandizing bullshit dies down, interviewing is going to continue to be a shitshow.

2

u/[deleted] Mar 30 '21

Just because you can do some algorithms doesn't make you a 'computer scientist'. Unless you're a PhD.

→ More replies (1)

0

u/[deleted] Mar 29 '21

[deleted]

24

u/angrymonkey Mar 29 '21

Asking junior developers questions about recursion, for example, is ridiculous

Uh, recursion is literally a CompSci 101 concept. I would hope that anyone aiming to get paid for programming would be able to understand it.

→ More replies (4)

17

u/telionn Mar 29 '21

Recursion questions can be good if they test practical skills. For example, tell me what this code returns when given 10:

int func(int n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return n + func(n / 2);
    else
        return n + func(n - 1);
}

If you have actual software experience, you shouldn't have any trouble figuring it out especially if you show your work. But if all you do is import modules and copy from StackOverflow, you might be in trouble.

On the other hand, asking them to write code and then saying "not like that, you have to use recursion" is a bad question.

8

u/gastrognom Mar 29 '21

23?

5

u/yakoudbz Mar 29 '21

10+5+4+2+1+1=23

Seems about right

→ More replies (3)

4

u/sammymammy2 Mar 29 '21

I was so confused as to what that function was supposed to compute and then I saw you had given a specific input, d'oh!

7

u/thephotoman Mar 29 '21

I'd expect someone fresh out of college to know how to traverse an arbitrary but finite tree.

7

u/przemo_li Mar 29 '21

Recursion is ridiculously easy and it's perfectly reasonable for junior developers to learn.

Blame Java for failure to tech recursion.

(*) Specifically speaking about trail recursion. Recursion schemes may actually extend that to order forms, but they are useful themselves in more complex scenarios so...

7

u/thephotoman Mar 29 '21

Don't blame Java for that. Yes, it has issues with tail recursion optimization, but I've done a fair amount of work with recursion in Java. It's not like it really sucks unless you're trying to recurse in a situation where looping is what the JVM expects you to do in this case.

Blame bad teachers. Recursion is a topic that's notoriously difficult to explain.

→ More replies (1)

3

u/Varanite Mar 30 '21

Asking junior developers questions about recursion, for example, is ridiculous.

I would expect the average junior developer to be better at implementing a recursive solution due to being recently out of college. Recursion is much more prevalent in academics than in actual software development (in fact NASA banned recursive code because it is problematic in practical settings.)

2

u/quadrilateraI Mar 30 '21

NASA found it problematic in embedded software for spacecraft, that is a very tiny niche of 'practical settings'.

→ More replies (1)

2

u/Riael Mar 30 '21

Asking junior developers questions about recursion, for example, is ridiculous. Yet, I see it happen all the time.

Excuse you what?

...these are things you did in high school

...you should know them...

Where the fuck can I find companies that have these kind of interviews??????

0

u/[deleted] Mar 29 '21

[deleted]

3

u/maest Mar 30 '21

Programming is hard, so I prefer not asking anything about programming in my programming interview, lest the question is too hard.

→ More replies (24)

0

u/[deleted] Mar 29 '21

[deleted]

6

u/hairibar Mar 29 '21

Wait, where is recursion used in graphics? I work in videogames and can't think of any example right now. Is it a raytracing thing?

13

u/firefly431 Mar 29 '21

Not OP, but:

  1. raytracing (rendering equation)

  2. BVHs (including quad/octrees, etc.)

  3. animation (calculating skeleton transforms, parent-child hierarchies)

  4. stuff with bezier curves (rendering, intersection, closest-point finding, etc.)

  5. adding on to that, procedural geometry in general

Tree structures are pretty common throughout most types of software, so there's plenty of places to use recursion.

4

u/hairibar Mar 29 '21

Ah of course, I didn't think of transform hierarchies.

1

u/sammymammy2 Mar 29 '21

Do you typically just "reify the call stack" as it were when solving these problems? Like, stack = []; while len(stack) >0 { doWork(pop(stack)); }

3

u/firefly431 Mar 29 '21 edited Mar 29 '21

Is there a particular reason you're asking this question? I'm struggling to think of why you would want to do that except for ensuring that the stack doesn't overflow (usually these structures aren't that deep so it's not a big problem), or some kind of hatred for recursion. Recursion is nice for these problems because they give you ways to pass information both up (extra parameters) and down (return values) the call stack.

EDIT: see replies below for some reasons.

→ More replies (3)

3

u/elprophet Mar 29 '21

If you understand what reifying a stack is, you understand that recursion used a stack in the first place, and you understand recursion :)

5

u/angrymonkey Mar 29 '21

BVHs, BSPs, object and transform hierarchies, ray tracing, subdivision surfaces, B-splines, fractal noise, constraint propagation, linear interpolation...

1

u/Supadoplex Mar 29 '21

How do you use recursion to do linear interpolation?

3

u/angrymonkey Mar 29 '21

Bilinear, trilinear, and higher interpolations work by interpolating the results of a larger number of lower-dimensional interpolations.

0

u/[deleted] Mar 29 '21

[deleted]

9

u/Calavar Mar 29 '21 edited Mar 29 '21

Have you ever heard of traversing a scene graph? That's a recursive process, and it is one of the most fundamental parts of 3D rendering. This isn't ivory tower stuff - recursion is everywhere in programming and it has very real, very practical uses.

I think the problem with the way that recursion is taught is that CS profs (and even Medium bloggers) like to start with abstract examples like calculating the Fibonnaci sequence, which makes it seem like recursion is a mathematical curiosity and not something with real uses. It would be much better to teach recursion with a practical example like "Today I'm going to show you how to write a function that finds a file somewhere on your hard drive."

1

u/zanbato Mar 29 '21

This is a good example of the diversity of programming. It is not needed at all for the data processing work I'm normally doing, and although it can be applied a lot of times it's the wrong choice. But it's also really popular, and sometimes seen as being really clever. So whenever I see it on a test then in the interview I make sure to ask them about it to make sure they really understand why (or why not) to use it.

→ More replies (1)

0

u/[deleted] Mar 30 '21

[deleted]

2

u/-dag- Mar 30 '21

Requiring your employees to know these types of concepts by heart, repeatable on demand, doesn't have anything to do with the actual challenges they will be facing in their job nor with the skills 99% of the average programmer needs to do it.

I quite agree. There's a place for technical interviews but not this gotcha BS. If the job is about working with a particular tool/library/framework, ask questions about how that works and don't try to trick people as that mostly reflects the insecurity of the interviewer.

This is coming from an experienced compiler developer with a heavy computer architecture background. I eat this stuff for breakfast. But I still don't ask about it in interviews

2

u/[deleted] Mar 30 '21

, I do not see a practical use case for it.

Very simple....it’s the difference between knowing how to drive a car and knowing how to fix it when it misbehaves. It Is the difference between being able to change a spark plug and being able to recognize that the spark plug needs to be replaced.

2

u/-dag- Mar 30 '21

Actually, it doesn't say anything of the sort. When's the last time you had to fix a linked list? Does fixing a linked list indicate your ability to solve the actual problems you encounter at all?

So many people just assume on-the-job training is not a thing. It's not only a thing, it's essential.

1

u/[deleted] Mar 30 '21

Completely orthogonal to on-the-job training (and I never said one had anything to do with the other, so don't shove me in with the "so many people just assume" crowd.)

As for the analogy - I never suggested that you should FIX a sparkplug either, but recognizing that the problem you're having is due to a broken spark plug will help you fix the underlying issue that much more quickly.

Knowing how your tools and systems work is always beneficial -- you have more insight into how the system actually works. It gives you some intuition that helps with problem solving. Otherwise you get the "hand waving in the air, there's magic"

I've never forgotten the time I was working at a hedgefund and some developers were building some code which had to integrate with a library I built. When their system crashed they started inserting print statements to figure out where it was crashing. When I saw what they were doing, I asked to look at the stack trace and the answer was, "What's a stack trace"? They had no idea that they could view a history of the function calls to see exactly where their code was crashing.

They just didn't understand how the stuff worked under the covers and that ended up causing them to take far more time than was necessary to fix the problem.

So same thing --- it's not just about linked lists -- it's about deeply understanding how all the pieces work, how everything comes together and it makes you a better developer. When you're wondering why your virtual method in a subclass isn't being called from your (C++) constructor, well, knowing how the C++ VMT mechanism works will help you understand.....

Whether you learn them from books or from on-the-job training is irrelevant as long as you learn them.

On the other hand, if I'm going to hire someone to work on my product, I need them to already know basic programming concepts and such things as linked lists, trees, sorting algorithms, big O are basic programming concepts. I don't care HOW they learned them but to come into my shop, they need to be proficient with that stuff already --- hence I would absolutely be asking these kinds of questions (and have done so many times in the past)

0

u/[deleted] Mar 30 '21

[deleted]

1

u/-dag- Mar 30 '21

"But I only want to hand-optimize when the code has proven to be a problem "

0

u/[deleted] Mar 30 '21

[deleted]

1

u/-dag- Mar 30 '21

Sure, use the right tool for the job. But asking someone to implement a linked list gives absolutely no information about whether they understand the memory hierarchy implications.

0

u/[deleted] Mar 30 '21

[deleted]

1

u/-dag- Mar 30 '21

And what if it just doesn't cross their mind to bring it up? Do you at least hint at the trade-off you're looking for? Because there's like a hundred ways to answer open-ended questions about trade-offs.

0

u/[deleted] Mar 30 '21

[deleted]

1

u/-dag- Mar 30 '21

My apologies. The article is basically about interviewers not doing a good job and it seemed like you were arguing against the article, saying asking minute details about linked lists is a good idea.

0

u/[deleted] Mar 30 '21

[deleted]

→ More replies (1)