Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're not supposed to convert the whole array into a linked list, you're only supposed to convert the best path into a linked list. You'd do this by brute force, trying directions and backtracking when you ran into dead ends.</p> <p>Your path, the linked list, would need to look something like this:</p> <pre><code>struct PathNode { int coordX, coordY; PathNode * next, * prev; } </code></pre> <p>If I remember later, I'll draw a picture or something of this structure and add it to the post. comment on this post in a few hours to attract my attention.</p> <p>The list would always contain a starting point, which would be the first node in the list. As you moved to other positions, one after the other, you'd push them onto the end of the list. This way, you could follow your path from your current position to the beginning of the maze by simply popping elements off of the list, one by one, in order.</p> <p>This particular linked list is special in that it's two way: it has a pointer to both the next element and the previous one. Lists with only one of the two are called singly linked lists, this one with both is called a doubly linked list. Singly linked lists are one way only, and can only be traversed in one direction.</p> <p>Think of your linked list as giant pile of strings, each with a starting end and a finishing end. As you walk through the maze, you tie a string at every node you visit and bring an end with you to the next square. If you have to backtrack, you bring the string back with you so it no longer points to the wrong square. Once you find your way to the end of the maze, you will be able to trace your steps by following the string.</p> <blockquote> <p>Could you just explain what -> means exactly?</p> </blockquote> <p><code>-&gt;</code> is an all-in-one pointer dereference and member access operator. Say we have:</p> <pre><code>PathNode * p = malloc(sizeof(*p)); PathNode q; </code></pre> <p>We can access p's and q's members in any of the following ways:</p> <pre><code>(*p).coordX; q.coordX; p-&gt;coordX; (&amp;q)-&gt;coordX; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload