
Concept explainers
C++
Create a program:
Given a large text file with multiple strings, what would be the most efficient way to read the text file and count how many and which word appears the most repated word in a text file
Output : the first 25 most repated words
The text file's size is unknown.
I add an image for output
File.txt:
=================================================================
Chapter 1
The house stood on a slight rise just on the edge of the village.
It stood on its own and looked over a broad spread of West
Country farmland. Not a remarkable house by any means - it was
about thirty years old, squattish, squarish, made of brick, and
had four windows set in the front of a size and proportion which
more or less exactly failed to please the eye.
The only person for whom the house was in any way special was
Arthur Dent, and that was only because it happened to be the one
he lived in. He had lived in it for about three years, ever since
he had moved out of London because it made him nervous and
irritable. He was about thirty as well, dark haired and never
quite at ease with himself. The thing that used to worry him most
was the fact that people always used to ask him what he was
looking so worried about. He worked in local radio which he
always used to tell his friends was a lot more interesting than
they probably thought. It was, too - most of his friends worked
in advertising.
It hadn't properly registered with Arthur that the council wanted
to knock down his house and build an bypass instead.
At eight o'clock on Thursday morning Arthur didn't feel very
good. He woke up blearily, got up, wandered blearily round his
room, opened a window, saw a bulldozer, found his slippers, and
stomped off to the bathroom to wash.
Toothpaste on the brush - so. Scrub.
Shaving mirror - pointing at the ceiling. He adjusted it. For a
moment it reflected a second bulldozer through the bathroom
window. Properly adjusted, it reflected Arthur Dent's bristles.
He shaved them off, washed, dried, and stomped off to the kitchen
to find something pleasant to put in his mouth.
Kettle, plug, fridge, milk, coffee. Yawn.
The word bulldozer wandered through his mind for a moment in
search of something to connect with.
The bulldozer outside the kitchen window was quite a big one.
He stared at it.
"Yellow," he thought and stomped off back to his bedroom to get
dressed.
Passing the bathroom he stopped to drink a large glass of water,
and another. He began to suspect that he was hung over. Why was
he hung over? Had he been drinking the night before? He supposed
that he must have been. He caught a glint in the shaving mirror.
"Yellow," he thought and stomped on to the bedroom.
![ina@osboxes: ~/Kodning/Lab4
ina@osboxes:~/Kodning$ cd Lab4
ina@osboxes:~/Kodning/Lab4Ş make run
·/lab4
the: 2537
of: 1258
a: 1199
to: 1185
and: 1184
it: 797
he: 788
said: 672
in: 630
was: 607
you: 564
that: 536
: 486
i: 428
364 : חO
his: 348
arthur: 332
at: 328
for: 317
ford: 314
ina@osboxes:~/Kodning/Lab4$ []
II](https://content.bartleby.com/qna-images/question/359a1891-a6e6-42ff-9fa2-e97930deb46b/3c5ec266-ddba-4503-8253-2359acc7d184/n6iwk5u_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

- Suppose you are given a text file that contains the names of people. Every name in the file consists of a first name and last name. Unfortunately, the programmer that created the file of names did not guarantee that each name was on a single line of the file. Read this file of names and write them to a new text file sorted according to first name, one name per line. For example, if the input file contains Ed Marston Bob Jones Jeff Williams Fred Charles The output file should be Bob Jones Ed Marston Fred Charles Jeff Williams Use arrays to solve the problem.arrow_forwardWrite a C program that reads a text file "My_book.txt" and counts the number of characters, words, and lines in the file. Then, the program should write these counts to a new file "My_book_info.txt" in the following format: Number of characters: [count] Number of words: [count] Number of lines: [count]arrow_forwardProblem A straight line can be defined by a pair of points p1(x1, yı) and p2(x2, y2). The slope m of a line is defined as follow: У2 — У1 m = X2 - X1 Your program reads the points from a text file called 'points.txt’ which contains the coordinates of unknown number of pairs of points as shown in Figure 1. Each line contains four values x1, y1, x2, y2, where x1, yl are the coordinates of the first point and x2, y2 are the coordinates of the second point. 10 -2 7.5 -3.2 4 15.5 -4.6 21 -2 Зр 12.5 6. 2 5 -3 -6 10 3 10 15 Figure 1. Input file contains unknown number of point pairs Use Spider, to create the following files: (i) The input file 'points.txt' shown in Figure 1. Your Python program that reads from the input file 'points.txt', the coordinates of unknown number of pairs of points, computes the corresponding slopes then prints the results on the screen as shown in Figure 2. (ii) Line # X1 Y1 X2 Y2 slope 1 10.00 -2.00 7.50 -3.20 0.48 2 4.00 15.50 -4.60 21.00 -0.64 3 0.00 0.00 0.00…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





