2c03-review - 00074

2c03-review 00074 - Plenty of possible solutions all rather straightforward implementation of the algorithm presented in class 2[20 a[5 Compute the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 SE2C03. Sample solutions to the assignment 4. Total of this assignment is 231 pts. 100%= 205. Each assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right, and resubmit to me during class, office hours, or just slip under the door to my office. 1.[30] Implement Rat-In-Maze algorithm first in pseudo-code and next in either C or C++ or Java (your choice). Do not spend too much time on fancy GUI (unless you can easily take something from a shelf). Assume the following: input - a two dimensional maze + rat start position + cheese position output - the shortest path that the rat learned from its experience + the whole path it travelled. For this question you must provide: program listing, with good programming style, including instructive comments and well-intended code; Several test runs of your program on various input data; a diskette with both C (C++ or Java) file and executable file.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Plenty of possible solutions, all rather straightforward implementation of the algorithm presented in class. 2.[20] a.[5] Compute the failure function f for pat = abbababaaabab 1 2 3 4 5 6 7 8 9 10 11 12 13 a b b a b a b a a a b a b f(i) 0 0 0 1 2 1 2 1 1 1 2 1 2 g(i) 0 1 1 1 2 3 2 3 2 2 2 3 2 b.[15] Suppose that x = abaababaababbababaaababaabaababb and we want to know if text x contains pattern pat. How many character comparisons are required by the straightforward algorithm? How many character comparisons are required by procedure the KMP algorithm? Using straightforward algorithm a b a A b a b a a b a b b a b a b a a a b a b a a b a b b # of comparisons pass1 a b b 3 pass2 a 1 pass3 a B 2 pass4 A b b 3 pass5 a 1 pass6 a b b 3 pass7 a 1 pass8 a b 2 pass9 a b b 3 pass10 a 1 pass11 a b b a b a b a a a b a b 13 Total 33...
View Full Document

This note was uploaded on 12/10/2009 for the course CAS 2c03 taught by Professor Janicki during the Spring '03 term at McMaster University.

Ask a homework question - tutors are online