Develop a C++ PROGRAM which will find a hidden sentence in a list of random words Open this text file named shuffled_words.txt in your program If it matters, you may presume there are an even number of words in the file Place the contents of the file into an appropriate data structure in the following manner: Grab a pair of strings from the file (unless end of file is reached) Each string is separated by a space The first string is the key The second string is the value So both the key and value are strings Place the key/value pair into your data structure Words are chained together such that a key will give its value like normal, but that value may also be a key in the map, which can find another value and so forth For example... If... map["why"] = "hello" map["hello"] = "there" map["there"] = "everyone" map["everyone"] does not exist This means if I start with "why" and concatenate the map values together I get the sentence "why hello there everyone" There is only one sentence chained together in the entire text file. All other map entries are immediate dead ends. Take the giant word list, find the longest word chain as described above, and print out the sentence that chain makes.
Develop a C++ PROGRAM which will find a hidden sentence in a list of random words Open this text file named shuffled_words.txt in your program If it matters, you may presume there are an even number of words in the file Place the contents of the file into an appropriate data structure in the following manner: Grab a pair of strings from the file (unless end of file is reached) Each string is separated by a space The first string is the key The second string is the value So both the key and value are strings Place the key/value pair into your data structure Words are chained together such that a key will give its value like normal, but that value may also be a key in the map, which can find another value and so forth For example... If... map["why"] = "hello" map["hello"] = "there" map["there"] = "everyone" map["everyone"] does not exist This means if I start with "why" and concatenate the map values together I get the sentence "why hello there everyone" There is only one sentence chained together in the entire text file. All other map entries are immediate dead ends. Take the giant word list, find the longest word chain as described above, and print out the sentence that chain makes.
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
Related questions
Question
Develop a C++ PROGRAM which will find a hidden sentence in a list of random words
Open this text file named shuffled_words.txt in your program
- If it matters, you may presume there are an even number of words in the file
Place the contents of the file into an appropriate data structure in the following manner:
- Grab a pair of strings from the file (unless end of file is reached)
- Each string is separated by a space
- The first string is the key
- The second string is the value
- So both the key and value are strings
- Place the key/value pair into your data structure
Words are chained together such that a key will give its value like normal, but that value may also be a key in the map, which can find another value and so forth
- For example... If...
- map["why"] = "hello"
- map["hello"] = "there"
- map["there"] = "everyone"
- map["everyone"] does not exist
- This means if I start with "why" and concatenate the map values together I get the sentence "why hello there everyone"
There is only one sentence chained together in the entire text file.
All other map entries are immediate dead ends.
Take the giant word list, find the longest word chain as described above, and print out the sentence that chain makes.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education