Question: Choosing the appropriate Collections classes to use . Given below are descriptions of some computer programs. Each of them reads a text file from standard
Choosing the appropriate Collections classes to use. Given below are descriptions of some computer programs. Each of them reads a text file from standard input. For each of them, specify:
- Which APIs would you use. Choose from JDK APIs discussed in class: List/Map/Set
- Which implementations of the APIs would you use, e.g. LinkedList / HashSet / Tree ...
Describe how you would use the API to implement the program. Give pseudocode or describe step by step how your program would work. No need to write an actual program. Give the time complexity of your program in terms of the number of words or lines read (whichever is appropriate).
Try to make your programs as simple and efficient as possible. What the programs should do:
-
Print lines of the file in reverse order.
-
Print all different words in the file, each word printed exactly once (order not important).
-
Print all different words in the file, with each word print how many times it occurs in the file (order not important).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
