For this assignment you must construct the set data structure. Specifically, your sets will be storing playing cards, taken from a standard deck of 52 playing card (no joker!). Your solution must implement the following:
A class (or struct) to contain the playing card information (face and suite).
This class must be able to retrieve the face and suite
A print method which prints out: "Face of Suite" (Eight of Hearts, Queen of Spades, )
An implementation of a set.
Use a hash table (with either chaining or linear probing as the collision detection) to store your card objects.
The set property (every item must be distinct/unique) must be obeyed.
Efficient insertion of new card elements
Efficient search for elements (Both require a good hash function)
Print the contents of the set
The set union operation
The set intersection operation
The set difference operation
Once you have completed the set implementation, your solution must be able to do the following:
1. Load in four sets of playing cards (hand1.txt, hand2.txt, hand3.txt, hand4.txt), and place each in their own set. Note that there may be duplicate cards in each file, your set must handle those appropriately.
2. Determine if among the four sets, you achieve the universal set of playing cards Included in the assignment archive is deck.txt, which contains all 52 cards. Load deck.txt into a 5th set object and compare it with the result of unioning all four sets.
3. Determine the unique cards between sets (i.e. what cards does hand1 have that are not in hand2? Not in hand3? ). Are there any cards that are found in only one hand?
4. Determine the extra cards (cards which are found in multiple hands). What is the most common card present? (Note do NOT count cards that are entered multiple times into the data files, only count cards which are present in finished sets).
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.