In this blog you will find the correct answer of the Coursera quiz Java Programming Principles Software Design Coursera Week 3 mixsaver always try to brings best blogs and best coupon codes
 

Week- 3

N-Grams: Predictive Text

1.
Question 1
Here is the code for runMarkovZero.

11
1 public void runMarkovZero() {
2 FileResource fr = new FileResource();
3 String st = fr.asString();
4 st = st.replace(‘\n’, ‘ ‘);
5 MarkovZero markov = new MarkovZero();
6 markov.setTraining(st);
7 for(int k=0; k < 3; k++) {
8 String text = markov.getRandomText(500);
9 printOut(text);
10 }

Suppose the line

1
markov.setRandom(18);
is put between lines 7 and 8, as the first line in the body of the for loop. Which one of the following options best describes how this line affects the program?

1 point

Each of three randomly generated texts will all be identical.

You will get three distinct randomly generated texts.

You will get three randomly generated texts, but the second generated text has one new letter and then is identical to the first text minus one letter, and the third generated text has one new letter and then is identical to the second text minus two letters.

You will get three randomly generated texts, but the second generated text has the first line with new random text, but the remaining lines are identical to the first n-1 lines where the first text had n lines. The third generated text has the first line with new random text, but the remaining lines are identical to the first n-1 lines of the second text.

2.
Question 2
In the MarkovRunner class in the runMarkovZero method, set the random seed to 1024 and run this method on the file confucius.txt.

What is the first line of text output when this program runs?

1 point
Enter answer here

eeuefmespwhsfoyu, s giowhersa eell: bma s.7shni:.at.ttdr.w aknf

3.
Question 3
In the Tester class, run the program testGetFollowsWithFile with the string “o” and the file confucius.txt.

What is the size of the ArrayList of characters that follow “o”?

1 point
Enter answer here

10453

4.
Question 4
In the Tester class, run the program testGetFollowsWithFile with the string “he” and the file confucius.txt.

What is the size of the ArrayList of characters that follow “he”?

1 point
Enter answer here

3715

5.
Question 5
After the completion of the MarkovOne class to generate random text by finding all the characters that follow one character, set the random seed in the runMarkovOne method in the MarkovRunner class to 365. Then run runMarkovOne on the file romeo.txt.

What is the first line generated?

1 point
Enter answer here

y O wirs bloay Ger. fo. tifthy The, A My; st- ie d, s. bloulate,

6.
Question 6
After the completion of the MarkovFour class to generate random text by finding all the characters that follow four characters, set the random seed in the runMarkovFour method in the MarkovRunner class to 715. Then run runMarkovFour on the file romeo.txt.

What is the first line of text generated?

1 point
Enter answer here

man in a green, for that haste, for a foot in her from Tybalt!

7.
Question 7
After the completion of the MarkovModel class to generate random text by finding all the characters that follow N characters, set the random seed in the runMarkovModel method in the MarkovRunner class to 953 and pass in N as 7. Then run runMarkovModel on the file romeo.txt.

What is the first line of text generated?

1 point
Enter answer here

e uncle Capulet’s orchard. Enter an officer, and light- more

8.
Question 8
For the class EfficientMarkovModel, which one of the following is the best place to call the buildMap method?

1 point

In the setTraining method.

In the constructor.

In the getRandomText method before the for loop.

In the getRandomText method as the first line in the for loop.

In the setRandomText method after myRandom is set.

9.
Question 9
In the EfficientMarkovModel class, comment out the print statements in the printHashMapInfo method that prints out the map. Make sure printHashMapInfo is called right after the HashMap is built. Then in the MarkovRunnerWithInterface class call the runModel method on an EfficientMarkovModel of order 6 with seed 792 on the file confucius.txt.

How many keys are in the HashMap?

1 point
Enter answer here
10.
Question 10
In the EfficientMarkovModel class, comment out the print statements in the printHashMapInfo method that prints out the map. Make sure printHashMapInfo is called right after the HashMap is built. Then in the MarkovRunnerWithInterface class call the runModel method on an EfficientMarkovModel of order 5 with seed 531 on the file confucius.txt.

What was the size of the largest ArrayList in the HashMap?

1 point
Enter answer here

70162

 

10.

In the EfficientMarkovModel class, comment out the print statements in the printHashMapInfo method that prints out the map. Make sure printHashMapInfo is called right after the HashMap is built. Then in the MarkovRunnerWithInterface class call the runModel method on an EfficientMarkovModel of order 5 with seed 531 on the file confucius.txt.

What was the size of the largest ArrayList in the HashMap?

1549

 

 

Important Links: