C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
help in breadth first search Posted by frozenparata on 24 Apr 2006 at 5:57 PM
hi guyz,
i have the algorithms for BFS and DFS.Here is mine........
i tried implementing them and error occured.....can someone help me with code

/*Q = new queue
Q.enq(v)
mark v as visited
while Q is not empty ////////BFS
curr = Q.deq()
print curr
for each w in adj(curr)
if w is not visited
Q.enq(w)
mark w as visited*/

/////DFS

s = new stack
s.push(v)
mark v as visited
while s is not empty
curr =s.top()
if every vertex in adj(curr)
is visited
s.pop()
else
let w be an unvisited vertex in adj(curr)
s.push(w)
print and mark w as visited







 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.