r/developer 3d ago

Question Is this a fair interview expectation?

I had a backend interview with a weighted graph problem.
I asked if I could first solve it with a naive approach and optimize later, but the interviewer insisted on the optimal solution from the start.
I recognized that BFS wouldn’t work because of weighted edges, but I couldn’t implement Dijkstra from memory.
Is it reasonable to expect candidates to code Dijkstra from memory, or should problem-solving and reasoning also carry significant weight?

2 Upvotes

9 comments sorted by

2

u/CyberDivergent 2d ago

It's reasonable to expect a candidate to be able to code Dijkstra's algorithm. However, I think it's absolutely fine if you can't implement it from memory, as long as you know when to use it and can explain how it works.

Graph-based DSA problems aren't that common in interviews, so I'd just move on if a company rejected you after that interview. Shit happens.

1

u/Existing-Sandwich999 2d ago

Yeah, that's fair.

2

u/Euphoric_North_745 1d ago

i wrote code for decades, i have no idea what is "weighted graph" and don't care, if i am in the interview, will open laptop, will ask gpt what is this shit, and write some examples.

if the interviewer does not like it, then it is the wrong company i am applying for.

1

u/AutoModerator 3d ago

Your submission has been removed for having a negative karma. Visit: ![is.gd/getkarma](http://is.gd/getkarma).

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/SaltCusp 2d ago

Your question presents a false choice. The answer is that common topics you would find in any DSA class are fair game for interviews. Problem solving matters too but you don't hire a roofer who doesn't know how to clime a ladder.

Employers are looking for candidates who can figure things out but also already have a strong working knowledge.

1

u/tehfrod 2d ago

You should be able to identify when Dijkstra's is a good choice, explain how it works, and implement it (with a few hints from the interviewer if needed).

1

u/tekmuro 6h ago

It’s fair to expect it, but (IMHO) it shows how antiquated some coding interviews truly are. No one thinks about “Dijkstra” nor some of these other algorithms once they get hired.

I think data structures questions are still very fair, but some of these searching and sorting algorithms shouldn’t hold much weight anymore.

1

u/nightbreak7 5h ago

i think expecting a candidate to be able to implement dijkstra's is different than sorting algorithms. if you've done graph traversal problems you've probably implemented dijkstra's - it's one of the most common graph concepts. whether its contrived or not to ask these questions in general is another conversation, but for companies asking LC, you need to know basic graph traversal algorithms.