educative.io

Educative

Why are we implementing the LinkedList logic when java already has a class for doing it?

Just a small confusion. In interviews they don’t expect us to implement a DS and then use it to solve a question right? Wouldn’t it be faster and accurate to use the built-in classes?
I’ve had this question in my head for long and i just want to clear this out.

Hi @Harsh_Palod ,

This is Waleed from Educative.

First, it is no secret that the best way to learn to program is by doing it. Within programming, nothing beats the learning opportunity presented by implementing common data structures.

Second, many different people say that they understood how a data structure works only once they implemented it. One might say that we don’t need to understand how these data structures work because they are already implemented, just as one can say that I don’t need to know how a car works, only how to drive one. But, that statement is valid from the perspective of a casual driver, not of an automotive technician.

Furthermore, even for a casual driver, some knowledge of how the car works is useful when operating the car if a fault develops on a highway or when getting routine maintenance done. In a similar manner, knowledge of common data structures is essential for computer science practitioners because, without it, one can’t pick the best data structure for a particular problem. As I argued earlier, one can’t have the in-depth understanding of a data structure unless one has implemented it.

Thirdly, a small fraction of programmers do have to implement data structures in their daily coding jobs. Sure, the libraries are implemented by terrific programmers and these implementations are optimized is excellent ways. However, a library data structure is probably built to optimize for the common case. For a specific programming problem, dropping some of the baggage from a generic data structure might lead to better performance. In such a case, developing a customized data structure from scratch might be easier.

However, as far as interviews are concerned, knowing how a particular DS is implemented is relatively less of an importance than knowing when, how and why it is used in a particular problem. Having said that, I am in no way undermining the importance of DS implementation but most interviewers are more interested in the problem-solving skills of an applicant.

Best Regards,
Waleed | Developer Advocate
educative.io

1 Like

Thanks a lot Waleed for the detailed answer. I’m sure i realize the importance of DS implementation now. This clears my doubt thoroughly.

1 Like