Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the Lookup program given in the textbook ( program 4 . 4 . 1 ) to make a program LookupMultipleNumber that prints out multiple
Modify the Lookup program given in the textbook program to make a program LookupMultipleNumber that prints out multiple values having the same key. MO
Notes:
The user would specify the maximum number of values to be printed out for each key as a command line argument after the file name.
Store all such multiple values in a queue. So each element of the symbol table would have a string as a key and a queue object as its value.
Sample runs would be as follows refer to input file amino.csv
java LookupMultipleNumber amino.csv
Tryptophan
TGG
Cysteine
TGT TGC
Program Dictionary lookup
public class Lookup
public static void mainString args
Build dictionary, provide values for keys in StdIn.
In in new In args;
int keyField Integer.parseIntargs;
int valField Integer.parseIntargs;
String database inreadAllLines;
StdRandom.shuffle database;
ST st new ST;
for int i ; i database.length; i
Extract key, value from one line and add to ST
String tokens databaseisplit;
String key tokens keyField;
String val tokens valField;
stputkey val;
while StdIn.isEmpty
Read key and provide value.
String s StdIn.readString;
StdOut.printlnstgets;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started