{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

11-10 Class Notes CS 107

# 11-10 Class Notes CS 107 - 11-10 Class Notes CS 107...

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

Announcements : See changes to program #5 Questions? Last Time: Maze problem, comments on program Today: Finish the maze problem Comments on program #5 Linked List example (time permitting…) /** * Class Maze4 illustrates navigating a maze. * Once again the one-dimensional array representation is used. In * aaddition, an array is added to keep track of where we've come from, * and a boolean variable is added to mark when the solution has been * found to prevent further moves after the solution has been found. * * Running the program gives: 11, 12, 13, 22, 32, 42, 43, 44, 45, 46, 36, 26, 27, 55, 65, 64, 74, 84, 83, 82, 85, 86, 76, 77, 78, 88, Got to destination! * Pasted from < http://logos.cs.uic.edu/Examples%20And% 20Notes/notes/Java/Recursion/Maze1/Maze4.java > * Problems: * How can we display the solution path, with only the squares in the solution? */ public class Maze4 { private static int start = 11; // this is static so main() can use it private static int end = 88; // this is static so main() can use it private int[] maze = { /* 0 1 2 3 4 5 6 7 8 9 */ /* 0 */ 1,1,1,1,1,1,1,1,1,1, /*10 */ 1,0,0,0,1,1,1,1,1,1, /*20 */ 1,1,0,1,1,1,0,0,1,1, /*30 */ 1,1,0,1,1,1,0,1,1,1, /*40 */ 1,1,0,0,0,0,0,1,1,1, /*50 */ 1,1,0,1,1,0,1,1,1,1, /*60 */ 1,0,0,1,0,0,1,1,1,1, /*70 */ 1,1,1,1,0,1,0,0,0,1, /*80 */ 1,1,0,0,0,0,0,1,0,1, /*90 */ 1,1,1,1,1,1,1,1,1,1}; private int[] moves = {-1,-10,1,10};

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern