Help me about the Breadth-First-Search??

This is a discussion on Help me about the Breadth-First-Search?? within the General AI Programming forums, part of the Cprogramming.com and AIHorizon.com's Artificial Intelligence Boards category; I dont know how to input the start-information of the tree like this: A-> B -> C - > D ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    4

    Help me about the Breadth-First-Search??

    I dont know how to input the start-information of the tree like this:
    A-> B -> C - > D
    A-> E -> F
    B-> G
    C-> G -> H -> I
    D-> K
    Find the way from A to I by BFS
    What data structure i wish to use?? And how to declare it.
    Can you give me an example or a shortcut code?
    Thanks alot
    John

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Breath-first is a memory consuming search method, but is guaranteed to find a solution if one exists, even if the tree has infinite depth. The basic implementation is a queue.

    1) Push root to queue
    2) If queue is empty, stop with failure
    3) Pop element from queue (name it A)
    4) If A is the goal node, stop with success
    5) Push all child nodes of A to to the queue
    6) Repeat from 2)
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shortest Path Maze Solver (Breadth Search Help)
    By Raskalnikov in forum C Programming
    Replies: 5
    Last Post: 04-07-2009, 08:41 PM
  2. Using Breadth First Search
    By neandrake in forum C++ Programming
    Replies: 4
    Last Post: 05-06-2005, 06:13 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21