lab_003 - Homework Assignment 4 Word Ladder Overview: stone...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework Assignment 4 Word Ladder Overview: stone A tone a L one C lone clon S c O ons co N ns con E s cone Y M oney Word ladders were invented by Lewis Carroll in 1878, the author of Alice in Wonderland . A ladder is a sequence of words that starts at the starting word, ends at the ending word, In a word ladder puzzle you have to change one word into another by altering a single letter at each step. Each word in the ladder must be a valid English word, and must have the same length. For example, to turn stone into money , one possible ladder is given on the left. Many ladder puzzles have more than one possible solutions. Your program must determine a shortest word ladder. Another path from stone to money is stone store shore chore choke choky cooky cooey coney money Objectives Practice implementing and using a Queue data structure. Gain an understanding of algorithms used for efficient implementation. Practice working in small teams to solve problems, design algorithms and write code Instructions Your program will accept starting and ending words from the input file called "input.txt". Then, you read the dictionary file from the course web page at 121/dictionary.txt using the URL class and store it in a HashSet . Finally, you build a word ladder between starting and ending words There are several ways to solve this problem. One simple method involves using stacks and queues. The algorithm (that you must implement) works as it follows Get the starting word and search through the dictionary to find all words that are one letter different. Create stacks for each of these words, containing the starting word (pushed first) and the word that is one letter different. Enqueue each of these stacks into a queue. This will create a queue of stacks! Then dequeue the first item (which is a stack) from the queue, look at its top
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/19/2009 for the course CS 121 taught by Professor Reid-miller during the Spring '09 term at Carnegie Mellon.

Page1 / 4

lab_003 - Homework Assignment 4 Word Ladder Overview: stone...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online