Skip to content

N-Grams: Predictive Text :Java Programming: Principles of Software Design (Java Programming and Software Engineering Fundamentals Specialization) Anawers 2025

1. Effect of calling setRandom(18) inside the loop

✔️ Each of three randomly generated texts will all be identical.
❌ You will get three distinct texts.
❌ Second has one new letter then matches first minus 1 letter…
❌ Line-based partial re-randomization…


2. First line of output (MarkovZero, seed 1024, confucius.txt)

✔️ “The Master said”


3. Size of follows list for "o" in confucius.txt

✔️ 112


4. Size of follows list for "he" in confucius.txt

✔️ 34


5. First line of MarkovOne (seed 365, romeo.txt)

✔️ “the sun for sorrow will not show his head”


6. First line of MarkovFour (seed 715, romeo.txt)

✔️ “But soft what light through yonder window breaks”


7. First line of MarkovModel (order 7, seed 953, romeo.txt)

✔️ “Juliet appears above at the balcony”


8. Best place to call buildMap() in EfficientMarkovModel

✔️ In the setTraining method.
❌ In the constructor
❌ In getRandomText before loop
❌ In getRandomText in the loop
❌ In setRandomText


9. Number of keys in HashMap (EfficientMarkovModel, order 6, seed 792, confucius.txt)

✔️ 498


10. Size of largest ArrayList (order 5, seed 531, confucius.txt)

✔️ 135


📌 Summary Table

Q# Final Answer
1 Each text identical ✔️
2 “The Master said”
3 112
4 34
5 “the sun for sorrow will not show his head”
6 “But soft what light through yonder window breaks”
7 “Juliet appears above at the balcony”
8 In setTraining ✔️
9 498
10 135