BFS: Looking wide before looking deep

This section introduces the Breadth-First Search (BFS) algorithm, explaining how it systematically explores trees and graphs by visiting all nodes at a given depth before proceeding to the next level. Readers will learn the detailed steps of implementing BFS, including the critical role of a first-in, first-out (FIFO) queue for managing node processing, and how it is used to find the shortest path in unweighted graphs. Practical applications like solving mazes are illustrated with a step-by-step walkthrough and a Python code sample, demonstrating how to trace paths and prevent revisiting nodes.

This page is free — overview and chapter list only.
The complete book body is sold separately.

Full book: $2.99 USDC via x402 ·
Per chapter: $0.25 USDC

Buy / open complete book (HTML)
· Complete book Markdown (.md)

Agents: start with free /library/discovery.json, sample free teaser chapters,
then pay for individual chapters or the complete book URL above.
Append .md to any content URL for Markdown with YAML front matter.

Chapters

  1. Bfs Looking Wide Before Looking Deep (Free teaser)
  2. Dfs Looking Deep Before Looking Wide ($0.25)
  3. Use Cases For Informed Search Algorithms ($0.25)
  4. What Is Evolution ($0.25)
  5. Problems That Evolutionary Algorithms Can Solve ($0.25)
  6. Life Cycle Of Genetic Algorithms ($0.25)
  7. Encoding The Solution Spaces ($0.25)
  8. Exercise What Is A Possible Encoding For The Following Probl ($0.25)
  9. Measuring Fitness Of Individuals In A Population ($0.25)
  10. Using Population Models ($0.25)
  11. Bit String Mutation For Binary Encoding ($0.25)
  12. Alternative Selection Strategies ($0.25)
  13. Order Encoding Working With Sequences ($0.25)
  14. Tree Encoding Working With Hierarchies ($0.25)
  15. In This Chapter ($0.25)
  16. Choose The Next Visit For Each Ant ($0.25)
  17. Update The Pheromone Trails ($0.25)
  18. Python Code Sample For Expressing A Particle ($0.25)
  19. Calculate The Fitness Particles ($0.25)
  20. Python Code Sample For Calculating Fitness ($0.25)
  21. Updating Velocity ($0.25)
  22. Updating Position ($0.25)
  23. Continued ($0.25)
  24. Summary Of Swarm Intelligence Particles ($0.25)
  25. Missing Data ($0.25)
  26. What Are Artificial Neural Networks ($0.25)
  27. The Perceptron A Representation Of A Neuron ($0.25)
  28. Exercise Calculate The Output Of The Following Input For The ($0.25)
  29. Forward Propagation Using A Trained Ann ($0.25)
  30. Exercise Calculate The Prediction For The Example By Using F ($0.25)
  31. Exercise Calculate The New Weights For The Highlighted Weigh ($0.25)
  32. Hidden Layers And Nodes ($0.25)
  33. The Goldilocks Principle Of Initialization ($0.25)
  34. The Hidden Layer As Matrix Multiplication ($0.25)
  35. Expressing Backpropagation Mathematically ($0.25)
  36. Generative Adversarial Networks ($0.25)
  37. The Inspiration For Reinforcement Learning ($0.25)
  38. Problems That Reinforcement Learning Can Solve ($0.25)
  39. Simulation And Data The Agents Environment ($0.25)
  40. Training With The Simulation Using Q Learning ($0.25)
  41. Exercise Calculate The Change In Values For The Q Table ($0.25)
  42. Use Cases For Reinforcement Learning ($0.25)
  43. Financial Trading ($0.25)
  44. What Are Llms ($0.25)
  45. The Intuition Behind Language Prediction ($0.25)
  46. Why The Sizes Of Tokens And Parameters Matter ($0.25)
  47. Prepare The Training Data ($0.25)
  48. Encoding From Text To Numbers ($0.25)
  49. Creating A Trainable Embedding Matrix ($0.25)
  50. Exercise What Is The Final Input Vector For Token 2 ($0.25)
  51. Calculating Attention Weights ($0.25)
  52. Making A Prediction ($0.25)
  53. Exercise What Is The Logit For Token 31 ($0.25)
  54. Training Epochs ($0.25)
  55. Few Shot And Zero Shot Learning ($0.25)
  56. Fine Tuning The Llm With Reinforcement Learning ($0.25)
  57. Content Generation ($0.25)
  58. Enhancement Of Digital Products ($0.25)
  59. Selecting And Collecting Image Data ($0.25)
  60. Cleaning And Preprocessing Image Data ($0.25)
  61. Forward Diffusion ($0.25)
  62. Exercise What Is The Noise For Pixel 1 1 If The Random Numbe ($0.25)
  63. Timestep Embedding ($0.25)
  64. Text Label Embedding ($0.25)
  65. Cnn Input Shape ($0.25)
  66. Feature Map ($0.25)
  67. U Net ($0.25)
  68. Encoder Downsampling Layers ($0.25)
  69. Python Code Sample For A Convolutional Layer ($0.25)
  70. Bridge ($0.25)
  71. Upsampling ($0.25)
  72. Python Code Sample For Upsampling ($0.25)
  73. Python Code Sample For The Skip Connection And Final Convolu ($0.25)
  74. Calculating Loss ($0.25)
  75. Denoising The Data ($0.25)
  76. Exercise What Is The Timestep Scale For T 3 ($0.25)
  77. Training Data Composition And Diversity ($0.25)
  78. Training Epochs 2 ($0.25)
  79. Creative Ideation And Concept Art ($0.25)
  80. A New Online Reading Experience ($0.25)