I solve RGB puzzle using BFS, it is working correctly but i need to print the route which it used to find out the solution. I am a little bad with pointers, the parent pointer of the node i have is not traversing at all. It is always giving the last node as output.
spacer15:
On line 3 you wrote: obj.parent=NULL;
And as far as I can tell, you don't assign it any other value. Naturally the while loop while(temp.parent!=NULL){ is going to break out after the first while iteration because you assign obj to temp.
On line 68 you wrote: temp.parent=temp.parent->parent;
You only use the -> operator when you are using it on a pointer. temp is not a pointer. In this case, you should use temp.parent=temp.parent; but that statement is redundant. You need to change the temp variable before you try to determine if its parent is not NULL. Does that answer your question?
Well I didn't apply pointers anymore, I just made a string with each node object and appended it. It completed the solution. Well thanks for the help though. Topic closed. Bless you sir.