Size: 1642
Comment:
|
Size: 1707
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 5: | Line 5: |
= Assignment 2: Word Ladders = | = Assignment 2: Ordered Word Ladders = |
Line 7: | Line 7: |
A ''word ladder'' is a sequence of words * that are in alphabetic order * each word in the sequence differs from its predecessor by * changing one letter, e.g. ''born→barn'' * adding or removing one letter, e.g. ''band→brand'' |
An ''ordered word ladder'' is an alphabetically-ordered sequence of words where each word in the sequence differs from its predecessor by: * changing one letter, e.g. ''barn→born'' * adding or removing one letter, e.g. ''band→brand'' |
Line 18: | Line 16: |
Your assignment is to write a program that computes the longest word chain(s) that can be built from a set of words given on stdin. The output of your program is the maximum length of all the word chains that can be built from the input words, together with all the word chains that have this length. | Your assignment is to write a program that computes the longest word ladder(s) that can be built from a set of words given on stdin. The output of your program is the maximum length of all the word ladders that can be built from the input words, together with all the word ladders that have this length. |
Line 28: | Line 26: |
* there is no punctuation or digits in the input | |
Line 32: | Line 31: |
* Call your source program ''ladder.c'' (for submission purposes). * In ''ladder.c'' include the statement |
* Call your source program ''ladders.c'' (for submission purposes). * In ''ladders.c'' include the statement |
Contents
Assignment 2: Ordered Word Ladders
An ordered word ladder is an alphabetically-ordered sequence of words where each word in the sequence differs from its predecessor by:
changing one letter, e.g. barn→born
adding or removing one letter, e.g. band→brand
The following are examples of word ladders of different length:
ban→bar→boar→boat→boast, length 5
cab→can→cane→dame→date→mate→mite→site→size, length 9
Your assignment is to write a program that computes the longest word ladder(s) that can be built from a set of words given on stdin. The output of your program is the maximum length of all the word ladders that can be built from the input words, together with all the word ladders that have this length. You should also a complexity analysis (of time) using Big-oh notation.
The following conditions apply to the input:
- it may be empty
the words are alphabetically ordered, and must be lower case (a-z)
- no word is more than 19 letters
- there will be no more than 1000 words
- there is no punctuation or digits in the input
Some comments about the programming:
- There are no restrictions on using arrays.
- You should use ADTs, in particular stack, queue and graph ADTs, if possible.
Call your source program ladders.c (for submission purposes).
In ladders.c include the statement
This header file should contain the complexity analysis as a comment (hence use simple text). Obviously this header file should be submitted as well.