Goal Develop and implement a word ladder finder. Details A word ladder (aka doublet) is a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Goal Develop and implement a word ladder finder. Details A word ladder (aka doublet) is a type of puzzle created by Charles Dodgson (aka Lewis Carroll) in the 1800s. The premise of the puzzle is to "convert" one word into the other by a sequence of single-letter changes, with each change generating a valid English word. For example, you can change beer into wine via the sequence beer-beet - bent - lent-lint-line - wine. There may be other ladders for these words as well. Your program should begin by reading words from the file sgb-words.txt; the file consists of 5757 words used to test the Stanford GraphBase. Note that all words have exactly five letters. Each word should have two values connected to it: • A pointer to a word (and its connected data) • A linear list of pointers to other words Initialize the pointer for each word to NULL. Then, examine each pair of words- there are 16 568 646 such pairs. If the pair has a Hamming distance of 1, then add each word-a pointer to the word, actually to the other word's list. Read two five-letter words from the keyboard. Find both words in the word list. If either word is not in the list, stop and output that no word ladder exists. Otherwise, do the following algorithm. Preconditions w₁ and we are words in the word list Postconditions S contains a word ladder from w₁ to W₂ 1: procedure GENLADDER(W₁,W₂) Clear S 2: Add W₂ to a queue Q while Q is not empty do Dequeue Q into w 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: for each word v in w.list do if v.ptr = NULL then v.ptr - w Enqueue v in Q end if end for end while if w₁.ptr NULL then Append W₁ to S ww₁.ptr while w # NULL do Append w to S ww.ptr 16: 17: 18: 19: 20: 21: end procedure end if end while After running the algorithm, if S is empty then there is no ladder. Otherwise, display the contents of S in order to obtain the ladder. What to turn in Turn in your source code and Makefile. If you are using an IDE, compress the folder containing the project and submit that. Goal Develop and implement a word ladder finder. Details A word ladder (aka doublet) is a type of puzzle created by Charles Dodgson (aka Lewis Carroll) in the 1800s. The premise of the puzzle is to "convert" one word into the other by a sequence of single-letter changes, with each change generating a valid English word. For example, you can change beer into wine via the sequence beer-beet - bent - lent-lint-line - wine. There may be other ladders for these words as well. Your program should begin by reading words from the file sgb-words.txt; the file consists of 5757 words used to test the Stanford GraphBase. Note that all words have exactly five letters. Each word should have two values connected to it: • A pointer to a word (and its connected data) • A linear list of pointers to other words Initialize the pointer for each word to NULL. Then, examine each pair of words- there are 16 568 646 such pairs. If the pair has a Hamming distance of 1, then add each word-a pointer to the word, actually to the other word's list. Read two five-letter words from the keyboard. Find both words in the word list. If either word is not in the list, stop and output that no word ladder exists. Otherwise, do the following algorithm. Preconditions w₁ and we are words in the word list Postconditions S contains a word ladder from w₁ to W₂ 1: procedure GENLADDER(W₁,W₂) Clear S 2: Add W₂ to a queue Q while Q is not empty do Dequeue Q into w 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: for each word v in w.list do if v.ptr = NULL then v.ptr - w Enqueue v in Q end if end for end while if w₁.ptr NULL then Append W₁ to S ww₁.ptr while w # NULL do Append w to S ww.ptr 16: 17: 18: 19: 20: 21: end procedure end if end while After running the algorithm, if S is empty then there is no ladder. Otherwise, display the contents of S in order to obtain the ladder. What to turn in Turn in your source code and Makefile. If you are using an IDE, compress the folder containing the project and submit that.
Expert Answer:
Answer rating: 100% (QA)
maincpp include WordLadderh include using namespace std int main string dictFile wordBegin wordEnd outFile cout Enter the name of the dictionary file cin dictFile cout endl cout Enter the name of the ... View the full answer
Related Book For
Posted Date:
Students also viewed these electrical engineering questions
-
The project for SITXFSA004 Develop and implement a food safety plan consists of 2 parts, Part A and Part B. Part A requires you to review any existing food safety plan as this may exist in your...
-
A company is planning to develop and implement a new computerized purchase order system in one of its manu- facturing subsidiaries. The vice president of manufacturing has requested that internal...
-
Design and implement a word unscrambler game in Java. Instructions Your program should read in a random word from a file calledwords.txt (note the lack of capitalization) that you provide. Thefile...
-
11. What is the Specific Gravity of Zinc ? 12. The barometric pressure for the day is 14.7 psi. The hangar shop air tank gage reads 120 psi. What is the absolute pressure inside the shop air tank? =...
-
How long will you have to maintain a business that has an income of $5000 per year and expenses of $1500 per year if your initial investment was $28,000 and your MARR is 10% per year? (a) Less than 6...
-
Why should an organization seek to retain employees with performance or discipline problems - why not just fire them?
-
Builder Bee Equipment sells hand held engine analyzers to automotive service shops. Builder Bee Equipment started April with an inventory of 45 units that cost a total of \($5,760.\) During the...
-
Sam wants to help his brother, Lou, start a new business. Lou is a capable auto mechanic but has little business sense, so he needs Sam to help him make business decisions. Should this partnership be...
-
The force P causes point A to be displaced vertically by 2.60 mm. Part a: Determine the normal strain developed in wire AB . Part B: Determine the normal strain developed in wire AC . B 600 mm 30 600...
-
An experiment was conducted regarding a quantitative analysis of factors found in high-density lipoprotein (HDL) in a sample of human blood serum. Three variables thought to be predictive of, or...
-
Suppose you have A dollars today and wonder how much "purchasing power" this exact dollars amount will have 7 years from now, which we will call purchasing power P. We assume the formula P = A...
-
A boy throws a 0.19 kg stone into a river from a 15.0 m high bridge. If the initial speed of the stones is 12.0 m / s vertical downward, what is the stone kinetic energy and momentum of the stone as...
-
Blossom Company's income statement for the year ended December 31, 2025, contained the following condensed information. Service revenue $848,000 Operating expenses (excluding depreciation) $618,000...
-
7. Calculate the equivalent and total resistance as well as the current in the circuit. Calculate the current and voltage drop across each individual resistor (6 marks) 6.0 V V V = 6.0 V = 6.0 V R =...
-
Taylor suffered a ruptured disc during an automobile accident. On October 26, 1994, he underwent surgery at Louisiana State University Medical Center (LSUMC). After surgery, Taylor began to...
-
A person is driving along a straight highway at a speed of 2 2 . 0 m / s when the traffic light which is 4 0 . 0 m ahead turns yellow. Because of his \"reaction time\", there is a delay of 0 . 1 2 s...
-
a) c) Assign absolute configurations to the chirality centres in the following molecules: CH3 HC= CH3 CN ONC ECH H3Cu b) H CH3 CH HC d) HNC H
-
A researcher reports a significant two-way between-subjects ANOVA, F(3, 40) = 2.96. State the decision to retain or reject the null hypothesis for this test.
-
Most pressure to legislate and enforce copyright laws for software has come from North America and Western Europe and not from other parts of the world. Why?
-
1. Some Web sites are not very useful, functional, or well organized. Why do you believe that Web sites are approached differently than other software development initiatives? What did Wells Fargo do...
-
What are the potential risks of a single organization controlling much of the market for essential software?
-
Cruise Canada Motorhomes Inc. (CCM) was formed on January 1, 2020, when the company issued its common shares for \(\$ 200,000\). Early in January, CCM made the following cash payments: a. For...
-
Accountants for Crowne Plaza Products Inc. have assembled the following data for the year ended December 31, 2020: {Requirement} Prepare Crowne Plaza Products's statement of cash flows using the...
-
Top managers of Culinary Imports Limited are reviewing company performance for 2020. The income statement reports a \(15 \%\) increase in net income, the fourth consecutive year showing an income...
Study smarter with the SolutionInn App