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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education