How Can I Relearn Linked Lists, Stacks, and Queues in Java?
Asked by
!be right back!
I finished a Java data structures class, but only a month later I realized I've forgotten much of what I learned about stacks, linked lists, and queues. I want to rebuild my understanding and get comfortable programming with these structures again. Should I review my old notes and assignments, work through a particular book or course, or focus on building small projects?
Answers
The structures are fairly simple conceptually, but choosing the right one takes practice. A linked list is made of objects that reference other objects, while a stack is defined by last-in, first-out operations such as push and pop. A stack can be implemented with either an array or a linked list. Try implementing both versions and compare their strengths and limitations.
Reply to this answer
A good algorithms book can help, even if its examples use another language. The important part is understanding the underlying ideas; translating a short example into Java is useful practice. Review your old assignments too, since they show exactly what you were expected to know.
Reply to this answer
Build something small that gives you a reason to use these structures. For example, make a browser-history simulator with stacks, a simple queue-based task manager, or a linked-list collection. Struggling through implementation, debugging it, and fixing your mistakes will make the ideas stick much better than rereading a lecture.
Reply to this answer
Start with the concepts rather than memorizing Java syntax. Make sure you understand how each structure works internally, what operations it supports, its typical time costs, and when it is or isnโt a good choice. Once the idea is clear, implementing it in Java becomes much easier. Then practice writing each structure from scratch instead of relying only on the built-in classes.
Reply to this answer
Add your answer
Answers are reviewed before publication.
!be right back!: That makes sense. I think Iโve been focusing too much on remembering code instead of understanding why I would choose one structure over another.