art I: Define a “word” as a maximal length sequence of alphanumerics. For example, in the line   Hello, there! How are you? I am fine; how are you? My number is DE4-3656.   the words are “hello”, “there”, “How”, “are”, “you”, “I” “am”, “fine”, “how”, “are”, “you”, “My”, “number”, “is”, “DE4”, and “3646”.   Write a C program that reads lines from a file (you may assume it’s a text file) or files named on the command line, breaks them into words, stores the words in order (that is, ASCII order), and counts the number of times each word appears. Do not make any assumptions about the number of lines or words; but you may assume no word is over 256 characters long. When this is done, print the words and counts, as follows. This example is from the line above: 3646 (1) DE4 (1) Hello (1) How (1) I (1) My (1) am (1) are (2) fine (1) how (1) is (1) number (1) there (1) you (2) Call your file wordsort1.c. Hint: This is easiest done using a linked list, with each element a structure containing a pointer to the word and count. Part II: Now modify the wordsort1.c so that it prints the words in dictionary order rather than ASCII order. Dictionary order, sometimes called lexicographic order, intermixes upper-case and lower-case letters, so the upper-case letter precedes the corresponding lower-case letter. Digits precede all letters. Here is the same list as in the example in problem 1, but in lexicographic order: 3646 (1) am (1) are (2) DE4 (1) fine (1) Hello (1) How (1) how (1) I (1) is (1) My (1) number (1) there (1) you (2) Call your file wordsort2.c.   Part III: The “word” was defined as any sequence of alphanumerics. But this did not take into account words split over two lines. For example,   hel- lo   is really the word “hello”. The two parts are separated by a hyphen, perhaps some space, a newline, and perhaps more space. For this part, take your program wordsor

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

Part I: Define a “word” as a maximal length sequence of alphanumerics. For example, in the line

 

Hello, there! How are you? I am fine; how are you? My number is DE4-3656.

 

the words are “hello”, “there”, “How”, “are”, “you”, “I” “am”, “fine”, “how”, “are”, “you”, “My”, “number”, “is”, “DE4”, and “3646”.

 

Write a C program that reads lines from a file (you may assume it’s a text file) or files named on the command line, breaks them into words, stores the words in order (that is, ASCII order), and counts the number of times each word appears. Do not make any assumptions about the number of lines or words; but you may assume no word is over 256 characters long. When this is done, print the words and counts, as follows. This example is from the line above:



3646 (1)

DE4 (1)

Hello (1)

How (1)

I (1)

My (1)

am (1)

are (2)

fine (1)

how (1)

is (1)

number (1)

there (1)

you (2)

Call your file wordsort1.c.

Hint: This is easiest done using a linked list, with each element a structure containing a pointer to the word and count.



Part II: Now modify the wordsort1.c so that it prints the words in dictionary order rather than ASCII order. Dictionary order, sometimes called lexicographic order, intermixes upper-case and lower-case letters, so the upper-case letter precedes the corresponding lower-case letter. Digits precede all letters.

Here is the same list as in the example in problem 1, but in lexicographic order:



3646 (1)

am (1)

are (2)

DE4 (1)

fine (1)

Hello (1)

How (1)

how (1)

I (1)

is (1)

My (1)

number (1)

there (1)

you (2)

Call your file wordsort2.c.

 

Part III: The “word” was defined as any sequence of alphanumerics. But this did not take into account words split over two lines. For example,

 

hel-

lo

 

is really the word “hello”. The two parts are separated by a hyphen, perhaps some space, a newline, and perhaps more space.

For this part, take your program wordsort1.c and modify it so it will handle words that are split over 2 lines, as above.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning