r/javahelp • • May 07 '20

Codeless Java Developers: what are the common data structures you usually use on production

To professional java dev here, what are the common data structure youve been using and which data structure you strongly suggest for beginners, like me, to study carefully

40 Upvotes

38 comments sorted by

View all comments

2

u/[deleted] May 07 '20 edited May 07 '20

Which datastructure should be used hardly depends on which use-case you got.

Data structures do have advantages or disadvantages when it comes to accessing / inserting / deletion and searching (of) values.

You will mostly try to determine based on the use-case which of this operations is the most crucial in your case and you select a datastructure which is fitting your needs and gives you the best performance overall.(Performance in this case can be a better time or space complexity depending on what you need for your application )

You can determine this by using the BigO Notation which tells you pretty much which data structure is the best choice for your use case.

I think if you take a look at the big o cheat sheet you can pretty much see all the commonly used data structures and i think its not a bad idea to implement them once for yourself so you have a better picture of what is happening behind the scenes.(I had to do that in my course at university back in the day as cs student and i can say it comes in handy when you try to implement algorithms like for example a dijkstra algorithm or anything like this when you are familiar with graphs and graph theory .)

You should definitly know how linked lists work , how stacks work and queues.Also it is pretty good to know about graph theory and graphs in general and know how to implement a B-Tree a binary tree an AVL tree and stuff like that.Also you should know about Hash tables and how they are implemented. It is not crucial to know about this stuff to use them but it will definitly give you a good understanding about why and how they are used in the most useful way.

You should take a look at this cheat sheet ( https://miro.medium.com/max/1400/1*wv3W3jYq7EHCDiwYVaCXrA.png ) and look at the left side where data structures are displayed and the worst case and average complexity. Also knowing about BigO Notation comes in very handy when it comes to determine which data structure is the right one for your use-case.

Experienced java dev here btw.

(Edit:

I want to add this youtube link for you for the big o notation , i think

this dude explains it quite well.

https://www.youtube.com/watch?v=D6xkbGLQesk.

Also here is a series of the same guy on data structures which the big o notation

video is a part of.

https://www.youtube.com/watch?v=bum_19loj9A

To also answer your question somehow:

Lists and maps are heavily used.Also sets and arrays ofc.

Which ones?

That depends on the use case because the implementation of different lists give you different results when it comes to space and time complexity.

)

Have fun learning ! :)

2

u/[deleted] May 08 '20

Cs Dojo is a cool man. :) been watching some of his videos but not yet encountered these links. Thanks btw