Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How could I go about implementing both a stack and linked list in a program that tracks books in a library in c++

I am very new to programming and currently undertaking a programming degree, I’m required to create a simple library management system using both a linked list and a stack in c++ I can probably make the whole system using just a linked list and a class that stores the book details but the TA demands that I use both. How do I use both in this situation?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I assume, by library management system, you mean a simple program to manage standard functions to handle an actual library (like borrowing books). If you need to develop a system to handle literature in an article (like BibTeX or EndNote), please comment :).

Okay so what do we need to manage a library? The most basic functions are imho:

  • search for a specific book
  • see all books in a category
  • borrow a book
  • return a book
  • see your borrowed books

For the search and the categories, a linked list is perfect. To save your borrowed books, you could use a stack, as you basically always want to show all of them and the stack is the simpler datastructure. Of course you could also just use a property of the book, if and who borrowed it and show all the books tagged as borrowed by you, when displaying your borrowed books, if you want to optimise for space, but this could be slow as you have more books in the library than in your "bag".
Another great application for the stack in this case is in the borrowing process, if you want to keep the history of who borrowed the book. you can just push the user to the stack as they are the last ones to borrow it for now.

This is just some ideas, hope it helped! 🙂

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading