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 6900523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:33:23+00:00 2026-05-27T07:33:23+00:00

I am to generate a solution to a maze using a linked list implementation

  • 0

I am to generate a solution to a maze using a linked list implementation of a stack in some way. The maze is read in from a .txt file and consists of 0’s for open spaces and 1’s for walls. enter image description here
<- Pretty sure an exit must be in the bottom row? So those three 0’s?

The algorithm I am attempting to use is:

While Not At End
    If Can Go North
        Go North
    ElseIf Can Go East
        Go East
    ElseIf Can Go South
        Go South
    ElseIf Can Go West 
        Go West
    EndIf
Wend

The way I’ve been attempting it relied on the ++ operations executing within an array index. I was unaware the array subscript operator [ took precedence over ++ so now I need to rethink a work around. Before doing so, I want to make sure this method will even work in first place. Could anyone take a look at my algo code thus far and provide some feed back? (Note: I still need to add in some code to track paths taken to avoid some type of infinite loop)

bool notSolved = true;
        int path = 0;
        row = 0;
        col = 0;

        rowStack.push(row);
        colStack.push(col);

        while (notSolved){

        //(from perspective of person looking at maze on screen)
        if (maze[row--][col] == 0){//if you can go up, go up
        rowStack.push(row);
        colStack.push(col);
        path++;
        }
        else if (maze[row][col++] == 0){//else if you can go right, go right
        rowStack.push(row);
        colStack.push(col);
        path++;
        }
        else if (maze[row++][col] == 0){//else if you can go down, go down
        rowStack.push(row);
        colStack.push(col);
        path++;
        }
        else if (maze[row][col--] == 0){//else if you can go left, go left
        rowStack.push(row);
        colStack.push(col);
        path++;
        }

            if((maze[row][col] == 0) && (row == (size - 1))){//if we reached an exit
                cout << "Solution Path:" << endl;
                for (int i = 0; i < path; i++){
                    cout << "row:" << rowStack.top() << " col:" << colStack.top() << endl;
                    rowStack.pop();
                    colStack.pop();
                }
            notSolved = false;
            }
        }

Problem with executing [ before ++:
enter image description here

Any help appreciated, Thanks!

  • 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-27T07:33:24+00:00Added an answer on May 27, 2026 at 7:33 am

    Your algorithm will not work in certain mazes that have circular paths: once you get into one of these, you’ll be going in circles. To fix this, you need to add a boolean array visited[R][C][DIR], where DIR is a number from zero to three representing a direction. When you leave cell [r][c] in the direction [d], set visited[r][c][d] to true. Next time you visit the same cell, see if you have left it in the same direction before; if you did, skip that direction, and go for the next one down the line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Orbeon Forms solution to generate messages from filled-in web forms.
Are there any API/solution to generate PDF report from XML file data and definition.
I generate some png charts and excel files using a mysql database. I display
Is their a solution to generate an email template using an ASP.NET MVC View
How can i generate bytecode (Byte[]) from a String at runtime, without using a
I need to generate xml file from controller after I find in google and
I'm looking for a solution to generate a checksum for any type of Java
I have an excel workbook vsto solution that needs to generate a pdf copy
Let's say I have a solution involving an iPhone app that generates some information
I'm trying to create a instruction list using ordered lists (ol). Inside I want

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.