How the breadth-first-search run? Can anyone shows me the source code?
How the breadth-first-search run? Can anyone shows me the source code?
ah, i might knew that you are getting your TARC assignment right ???
ok ok ... here's the clue...
try to look at the question and the example that given, see how the searching point look at, and how it's move.
Use a queue (instead of a stack or direct child manipulation)
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
it is something like this, but of course without the object stuff. This should at least give you the basic idea then you can write it in plan C.
Code:void printBFS(Node root) { Queue Q = new Queue(); if(roo != null) { Q.enq(root); } while(!Q.isEmpty()) { Node cur = Q.deq(); printf(cur); if(cur.left != null) { Q.enq(cur.left); } if(cur.right != null) { Q.enq(cur.right); } } }
Last edited by samps005; 12-08-2002 at 11:38 AM.