Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hlsxx/8-puzzle-cpp
Solving 8-puzzle with BFS and DFS algorithms
https://github.com/hlsxx/8-puzzle-cpp
8-puzzle 8-puzzle-cpp 8-puzzle-problem 8-puzzle-solver bfs bfs-cpp dfs dfs-cpp
Last synced: 5 days ago
JSON representation
Solving 8-puzzle with BFS and DFS algorithms
- Host: GitHub
- URL: https://github.com/hlsxx/8-puzzle-cpp
- Owner: hlsxx
- Created: 2023-12-28T19:58:17.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-28T20:00:29.000Z (about 1 year ago)
- Last Synced: 2024-11-09T09:26:13.763Z (2 months ago)
- Topics: 8-puzzle, 8-puzzle-cpp, 8-puzzle-problem, 8-puzzle-solver, bfs, bfs-cpp, dfs, dfs-cpp
- Language: C++
- Homepage:
- Size: 194 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 8-puzzle with C++
The 8-puzzle is a classic sliding puzzle that consists of a 3x3 grid with eight numbered tiles and one empty space. The goal of the puzzle is to rearrange the tiles by sliding them into the empty space, aiming to achieve a specific configuration, typically with the numbers arranged in ascending order.
![BFS](./images/8-puzzle.gif?raw=true "8-puzzle")
## Solve with BFS and DFS algorithms
Breadth-First Search (BFS) and Depth-First Search (DFS) are two fundamental algorithms used for traversing or searching graph and tree data structures.
## Example
Input matrix:
1 2 3
0 4 6
7 5 8### Breadth-First Search (BFS)
Depth: 3
Nodes count: 8![BFS](./images/bfs.jpg?raw=true "BFS")
### Depth-First Search (DFS)
Depth: 11
Nodes count: 12![DFS](./images/dfs.jpg?raw=true "DFS")