Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Problem You may be familiar with the kids game \"Where\'s Waldo?\" If so, yo

ID: 3621212 • Letter: T

Question

The Problem

You may be familiar with the kids game "Where's Waldo?" If so, you know that buried somewhere in a very complex picture is an image of the character Waldo, and your job is to find him. This assigment is similar - trying to find a particular (small) image embedded in a (large) picture.
Your Assignment

Your assignment is to write a class (named HW3) with the single method:

public static int[] findWaldo(char [][] image, char [][] waldo)

This method accepts an large image represented by a two dimensional array of characters, and another smaller image (Waldo). It returns pairs of row and column indices of the upper left corner of Waldo in the large image as successive two value pairs in the 2-element array. If Waldo does not appear in the image, return null. You can assume that the large image will always be at least as large as waldo.

Waldo will be represented by an array of characters. Every character in the waldo array must match every character in the image array, with the following exception. A period in the waldo array matches any character in the image array.

For example, given the image array:

dsleigheijasldkjfweifijl
abcdefgWwZZZW1lkijejfifj
hijklmnZAaZaZ2invnn,ie#v
opqrstuZZLlZZ3ivhbiensli
vwxyz12ZdZDdZ4qiur74nn9Z
3456789oZZoOZ5bvifj(838,
ke8784jflkav88hj3jf838jv
*%jie*^djfkei88738*)jeij

and the waldo array:

Ww...W1
.Aa.a.2
..Ll..3
.d.Dd.4
o..oO.5

your method should return the two element array [1,7] because the upper left corner of the waldo array appears in row 1 and column 7 of the image array and this is the only occurrence of Waldo in the image.

If Waldo occurs more than once, put each row/column of the upper left corner in the successive array elements. For example, if Waldo occured three times at [1,7], [4,10] and [15,45], then you should return a 6-element array with the values [1,7,4,10,15,45].

Two different Waldo occurrences in the image cannot overlap.

Both arrays will be rectangular. Both arrays will have at least one row and one column. The waldo array will never be larger than the image array in either dimension.
Testing

Write your own public static void main method to test your findWaldo method. Try various large and waldo images to insure your code works. Especially try putting waldo in the four corners of the large image, have the large image be exactly the same size as waldo, and have waldo missing from the image.


NOTE TO THE PERSON ANSWERING: I have most of the code written how I think it could work, I more or less just need to figure out how to "return null;" if there is no waldo in the array, and I need a good testing program for it using the array given in the text.

Explanation / Answer

This should give examples of everything you need: Source Code

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote