Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6844035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:19:35+00:00 2026-05-27T00:19:35+00:00

A matrix of 150×150 size will describe our labyrinth, so for example if the

  • 0

A matrix of 150×150 size will describe our labyrinth, so for example if the matrix were only 10×10 we would have something like this:

   1 1 1 1 1 1 1 1 1 1
   1 0 0 0 0 0 0 1 0 0<-F
   1 0 1 1 0 1 0 1 0 1 
   1 1 1 1 0 1 0 0 0 1
   1 1 1 1 0 1 1 1 1 1
   1 0 0 0 0 1 1 1 1 1
   1 0 1 1 0 1 1 1 1 1
   1 0 1 0 0 0 0 1 1 1
S->0 0 1 1 1 1 0 1 1 1
   1 1 1 1 1 1 1 1 1 1

Where S marks the starting point and F the exit of the labyrinth.
The purpose of this program is to generate a Binary Tree that will describe all the paths we traveled while trying to find the exit.

How would you acomplish that? I’m really lost this time, I don’t really know where to start that’s why I’m not posting anything I’ve tried but if you could please give me a direction I would be really really grateful.

John Smith.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:19:36+00:00Added an answer on May 27, 2026 at 12:19 am

    you might want to try backtracking

    here’s a complete example of how to solve this problem… however: it can’t operate on a maze with “islands” in it as it would be necessary to aditionally track where you have been already. but i think you can figure out how to do this as well…

    the output should be:
    right, up, up, up, right, right, right, up, up, up, up, right, right, down, down, right, right, up, up, right, finish!

    import java.awt.Point;
    
    public class Maze {
    
        enum Direction {
            up, right, down, left
        }
    
        static Direction[] dirs = Direction.values();
    
        int[][] maze = { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, { 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 },
                { 1, 1, 1, 1, 0, 1, 0, 0, 0, 1 }, { 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 },
                { 1, 0, 0, 0, 0, 1, 1, 1, 1, 1 }, { 1, 0, 1, 1, 0, 1, 1, 1, 1, 1 },
                { 1, 0, 1, 0, 0, 0, 0, 1, 1, 1 }, { 0, 0, 1, 1, 1, 1, 0, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } };
        Point start = new Point(0, 8);
        Point finish = new Point(9, 1);
    
        Point go(Direction dir, Point from) {
            Point result = new Point(from);
            switch (dir) {
            case up:
                if ((from.y == 0) || (maze[from.y - 1][from.x] != 0))
                    return null;
                result.translate(0, -1);
                break;
            case right:
                if ((from.x == maze[0].length) || (maze[from.y][from.x + 1] != 0))
                    return null;
                result.translate(1, 0);
                break;
            case down:
                if ((from.y == maze.length) || (maze[from.y + 1][from.x] != 0))
                    return null;
                result.translate(0, 1);
                break;
            case left:
                if ((from.x == 0) || (maze[from.y][from.x - 1] != 0))
                    return null;
                result.translate(-1, 0);
                break;
            }
            return result;
        }
    
        String tryToGo(Direction dir, Point from) {
            String result;
            Point newPosition = go(dir, from);
            if (newPosition == null)
                return null;
            else if (newPosition.equals(start))
                return null;
            else if (newPosition.equals(finish))
                return "finish!";
            else {
                for (Direction newDir : dirs) {
                    switch (newDir) {
                    case up:
                        if (dir == Direction.down)
                            continue;
                        break;
                    case down:
                        if (dir == Direction.up)
                            continue;
                        break;
                    case left:
                        if (dir == Direction.right)
                            continue;
                        break;
                    case right:
                        if (dir == Direction.left)
                            continue;
                        break;
                    }
                    result = tryToGo(newDir, newPosition);
                    if (result == null)
                        continue;
                    else
                        return newDir + ", " + result;
                }
                return null;
            }
        }
    
        public static void main(String[] args) {
            Maze maze = new Maze();
            System.out.println("right" + maze.tryToGo(Direction.right, maze.start));
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a matrix of data (with row names and column names). I would
I have a 2d matrix created with the code: for(i=0; i < size; i++)
I have a Matrix: close close.1 close.2 1 38.050 22.320 23.115 2 37.650 22.150
I have a 2D matrix, say M=zeros(10,10); I have another column matrix, V=[1;2;3;4;5;6;5;4;3;2]; I
I have a matrix of data (the columns represent time, and the rows spectrum
I have an R matrix with nonnegative numeric values. The matrix is effectively a
I have implemented one matrix multiplication with boost::numeric::ublas::matrix (see my full, working boost code
I have got a matrix which gives me a 2-dimensional discrete distribution (N²->R) in
Suppose I have a matrix of weights, and another matrix of data values. Can
I am looking to input criteria as the size of the matrix decreases each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.