Ask Question
3 April, 23:55

What are the best data structures to create the following items? And why? Designing a Card Game with 52 cards. Online shopping cart (Amazon, eBay, Walmart, Cosco, Safeway, ...) Online waiting list (De Anza College class waiting list, ...) Online Tickets (Flight tickets, concert tickets, ...)

+1
Answers (1)
  1. 4 April, 00:11
    0
    The best data structure in storing card is an array.

    The best choice for a shopping cart is hash-maps. the advantage of harsh mark is that they are dynamic in nature.

    Waiting lists are managed by a method called the First In First Out. when an individual is waiting for too long, he or she should be given the first chance for service.

    Sorted links are a better options for storing tickets.

    Step-by-step explanation:

    Solution

    In other to store the cards the best structure to be applied here is an array.

    Now, we are aware the array size, which comprises of 52 items, and hence card vales can be easily stored For standard 52-deck cards, a 2D array of size 4x15 can also be applied, with 4 being color count, and 13 being card in each color.

    In this example, the better option for shopping cart is hash-maps, because it is dynamic in nature for instance, when items are removed and more often, and also, there is a need for mapping of item ID or name to its actual database, so these values can be kept or stored as key-value pairs.

    Waiting lists are normal managed in a way of First In First Out, since a person is waiting longer should be given the first chance for service. this FIFO method is best used by a Queue. so this online waiting list can best be used by a queue.

    For tickets storing, a better option will be the sorted linked lists. because the tickets are to be stored in a large amount, and there will be deletions and insertions in large quantity. so keeping them in a sorted list will reduce the resource usage and the trade-off made as high search time will also have less effect, as there will be a limited number of searches.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What are the best data structures to create the following items? And why? Designing a Card Game with 52 cards. Online shopping cart ...” in 📗 Mathematics if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers