Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Programming Assignment 2 on Algorithm Analysis and Design | CPSC 5115U, Assignments of Computer Science

Material Type: Assignment; Professor: Bosworth; Class: Algorithm Analysis and Design; Subject: Computer Science; University: Columbus State University; Term: Fall 2008;

Typology: Assignments

Pre 2010

Uploaded on 08/04/2009

koofers-user-bqo
koofers-user-bqo 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC 5115 Algorithm Analysis and Design
Program 2 Due Friday, October 31, 2008
A “word trail” is a sequence of words, each formed from the previous word by a single letter
change. The following is a word trail from “CAT” to “TAR”
“CAT” “CAR” “TAR”
Define the distance between two words as the number of letters that differ. Thus
dist (“CAT”, “CAR”) = 1 as the third letter differs
dist (“CAR”, “TAR”) = 1 as the first letter differ
dist (“CAT”, “TAR”) = 2 as the first and third letters differ.
The programming assignment is to use the Breadth First Search. Specifically, the requirements
for the program include:
Read in the following list of words from a text file. Keep the words in UPPER CASE.
BAG BOW DOG MOB
BAR BOX EAR NOW
BAT CAT EAT ROB
BIG COW FAT ROW
BOG DIG FOX TAR
You may use either the adjacency matrix or adjacency list method or representing the graph. See
page 30 of the textbook for details on this. Each of the 20 vertices in the graph is to be labeled
with the three letter word associated with it.
The edges in the graph are to connect vertices with a single letter difference in the label. Thus,
there is an edge from “BAG” to “BAT” and “BAG” to “BAR”, but not “BAT” to “BOX”.
The program is to find a word trail from “DOG” to “CAT” by doing a BFS, beginning at the
node labeled “DOG”. All program output is to be to a text file.
Required output for this program includes.
1) A list of all vertices by label and the adjacency list for each vertex; e.g.
BAG => BAR => BAT => BIG => BOG
2) A list of all words on the word trail starting with DOG and ending with CAT.
My solution to this has six words in the trail, DOG, CAT, and four others.
Three files are to be submitted for this assignment:
1) the text input file
2) the text output file, containing the output shown above
3) a program file in text form.
Do not submit executable files, as I can generate them if needed.
Do not submit any file in zipped format.
Page 1 of 2 pages
pf2

Partial preview of the text

Download Programming Assignment 2 on Algorithm Analysis and Design | CPSC 5115U and more Assignments Computer Science in PDF only on Docsity!

CPSC 5115 Algorithm Analysis and Design

Program 2 Due Friday, October 31, 2008

A “word trail” is a sequence of words, each formed from the previous word by a single letter change. The following is a word trail from “CAT” to “TAR” “CAT” “CAR” “TAR” Define the distance between two words as the number of letters that differ. Thus dist (“CAT”, “CAR”) = 1 as the third letter differs dist (“CAR”, “TAR”) = 1 as the first letter differ dist (“CAT”, “TAR”) = 2 as the first and third letters differ. The programming assignment is to use the Breadth First Search. Specifically, the requirements for the program include: Read in the following list of words from a text file. Keep the words in UPPER CASE. BAG BOW DOG MOB BAR BOX EAR NOW BAT CAT EAT ROB BIG COW FAT ROW BOG DIG FOX TAR You may use either the adjacency matrix or adjacency list method or representing the graph. See page 30 of the textbook for details on this. Each of the 20 vertices in the graph is to be labeled with the three letter word associated with it. The edges in the graph are to connect vertices with a single letter difference in the label. Thus, there is an edge from “BAG” to “BAT” and “BAG” to “BAR”, but not “BAT” to “BOX”. The program is to find a word trail from “DOG” to “CAT” by doing a BFS, beginning at the node labeled “DOG”. All program output is to be to a text file. Required output for this program includes.

  1. A list of all vertices by label and the adjacency list for each vertex; e.g. BAG => BAR => BAT => BIG => BOG
  2. A list of all words on the word trail starting with DOG and ending with CAT. My solution to this has six words in the trail, DOG, CAT, and four others. Three files are to be submitted for this assignment:
  3. the text input file
  4. the text output file, containing the output shown above
  5. a program file in text form. Do not submit executable files, as I can generate them if needed. Do not submit any file in zipped format. Page 1 of 2 pages

Here is one drawing of the graph.

Here is my adjacency matrix.

  • CPSC 5115 Programming Assignment 2 Due October 20, - BAG BAG BAR BAT BIG BOG CAR CAT BOW BOX COG COW DIG DOG - BAR - BAT - BIG - BOG - CAR - CAT
    • BOW
      • BOX
    • COG
    • COW - DIG
    • DOG