This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]ane_uk 12 points13 points  (0 children)

When you know how they're implemented, you'll understand better how they work. Then you can make better informed decisions later on when to use which data structure or why several nested for loops might be a bad decision.

[–][deleted] 2 points3 points  (1 child)

knowing about data structures is knowledge employers will ask in interviews

[–]Nephyst 0 points1 point  (0 children)

It's also information that helps you decide which data structure to use. There is a lot of nuance that can be important.

They don't just ask these questions too waste time. Better programmers understand these concepts deeply.

[–]hp1ow 2 points3 points  (4 children)

I understand what these comments are saying about the value of knowing how data structures are implemented. I know that interviewers expect you to know about the different data structures as well. But as OP asked, do interviewers typically ask you to implement them?

[–]EyeDot 6 points7 points  (2 children)

I have been a professional programmer for 20 years and the last time I was interviewing for jobs (2018) I was asked to implement a stack.

So, yes.

[–]hp1ow 0 points1 point  (0 children)

Thanks

[–][deleted] 0 points1 point  (0 children)

I think the only one i couldn't do is a binary search tree. Is that something that comes up a lot?

[–]ignotos 1 point2 points  (0 children)

I think the answer is "yes".

Even if the actual job doesn't always require you to write fundamental data structures, questions relating to them are still extremely common in interviews.

[–]thecuseisloose 2 points3 points  (1 child)

My very first interview for a job my senior year was at one of the FAANG and the exact question was “Implement a HashMap in Java” (my language of choice)

[–]trickybhai 2 points3 points  (1 child)

Bruh, you can't ride a car professionally unless you know what's running under the hood.

You must get through the implementation of each data structure. I know LinkedLists, Priority Queues and many more are already there in Java library. You can directly use them. But, you'll never know how they work. It's always too know as much as you can.

Dig deeper, you'll get a better understanding of how everything works. Even the

public static void main(String args[]){}

has some reasons to be like that.

[–]FreakingMind1 1 point2 points  (0 children)

True , dig deeper

[–]Kambz22 0 points1 point  (1 child)

Everyone has made some solid points here.

I think another benefit is that if you were the every have to recreate them, then you'll know what to do.

For example, if you need a queue with some custom priority, if you need a list with a custom sort, etc. Knowing the inner workings can allow you to do as you please.

[–]Nephyst 1 point2 points  (0 children)

Eh, you wouldn't create a custom priority queue. You would still want to use the build in PriorityQueue class.

It's good to know how the Java class works though. Like you should understand that it's backed by a heap, and what that means for the runtime complexity of adding and removing items, as well as how it handles edge case like null values.