Question: For (a-c) below, determine what is the best data structure to use out of the ones we discussed in class: List, Set, Map. If more
For (a-c) below, determine what is the best data structure to use out of the ones we discussed in class: List, Set, Map. If more than one acceptable answer exists, use the most efficient one (with respect to runtime) that has the power you need. Also say what type you use: LinkedList vs. ArrayList, HashSet vs. TreeSet or HashMap vs. TreeMap. Please provide a brief explanation.
(a) (7%) You are working on a banking program. Each day, the checks for one account are processed and (assuming they dont bounce) an appropriate Check object is added to the Account object, to wait for end-of-month pro- cessing to write the bank statement. The check objects have fields number (of type int), received (of type Date) and amount (of type Money) and must be kept in original order by time of arrival, and are only used once (in our simplified system) to write the statement, where they are reported in the same order.
List< _______________________ >, Set< ________________ >, Map< _________________ , __________________>
(b) (7%) In the same banking scenario, each account has a unique id (an Integer) and one or more owners identified by social security numbers (also ints). Also bank account holders may have several accounts, each with a unique id. Ex- plain how you can use two Collections API classes working together to support looking up the bank accounts ids for given social security numbers.
List< _______________________>, Set< _______________________>, Map< _______________________, _______________________>
(c) (6%) You want to be able to display the courses a student took (represented as Strings, like CS310) and their grades (represented as Characters between A and F, assume there are no A- grades etc.), sorted by the grade. Explain briefly.
List< _______________________>, Set< _______________________>, Map< _______________________, _______________________>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
