Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

package hw1;

import java.util.Arrays;

import dsUtils.WordReader;

public class WordFrequencyAnalyzer {
/**********************************************************************************/
/* You are not allowed to add any fields to this class beyond the one given below */
/* You may only read in from the file once. This means you may only use a single */
/* word reader object. */
/**********************************************************************************/

// Currently, the field counters is not used.
// Your task is to make this class more efficent by storing the word counts
// as a symbol table / map / dictionary in the field counters.
private SequentialSearchST<String, Integer> counters;

private String filename;


/**
* Stores a count of the number of times any word appears in a file. The file is
* read in exactly once at the time time this object is constructed.
* (You need to modify the constructor to do this.)
*
* @param filename the name of the file on which to count all word occurrences.
*/
public WordFrequencyAnalyzer(String filename) {
this.filename = filename;
}

/**
* Returns the number of times a given word appears in the file from which this
* object was created.
* (Currently, it reads through the entire file to count the number of times
* the given word appears. Modify this to instead use the information stored
* in the counters field.)
*
* @param word the word to count
* @return the number of times <code>word</code> appears.
*/
public int getCount(char[] word) {
WordReader r = new WordReader(filename);
int count = 0;
for(char[] w : r) {
if (Arrays.equals(w, word))
count++;
}
return count;
}

/**
* Returns the maximum frequency over all words in the file from which this
* object was created.
* (Currently, this method is not implemented. You must implement it.)
*
* @return the maximum frequency of any word in the the file.
*/
public int maxCount() {
throw new RuntimeException("Not implemented.");
}
}

Only solve for maxCount

Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

What would be the print Statement for the code above?

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

What would be the print Statement for the code above?

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY