|
1 | 1 | #include <bits/stdc++.h>
|
2 | 2 | using namespace std;
|
3 |
| - |
| 3 | +/** |
| 4 | + * @file |
| 5 | + * @brief Implementation of Iterative deepening Search algorithm |
| 6 | + * @author [Sushant Kogurwar](https://github.com/sushskvnitn) |
| 7 | + */ |
4 | 8 | #define N 3 // Define the size of the tile puzzle (3x3)
|
5 | 9 |
|
6 | 10 | /**
|
@@ -48,8 +52,30 @@ class Node {
|
48 | 52 |
|
49 | 53 | /**
|
50 | 54 | * @class Solve8TilePuzzle
|
51 |
| - * @brief Solves the 8-tile puzzle using iterative deepening search. |
| 55 | + * @brief A class to solve the 8-tile puzzle using Iterative Deepening Search (IDS). |
| 56 | + * |
| 57 | + * @details |
| 58 | + * This class implements a solution for the 8-tile puzzle, where the goal is to |
| 59 | + * rearrange the tiles from a given initial state to a specified goal state. |
| 60 | + * The algorithm uses Iterative Deepening Search, which combines the benefits of |
| 61 | + * depth-first search (space efficiency) and breadth-first search (completeness). |
| 62 | + * |
| 63 | + * The initial state of the puzzle is provided by the user, and the algorithm |
| 64 | + * checks if the puzzle is solvable based on the number of inversions in the array. |
| 65 | + * If the puzzle is solvable, it attempts to find the solution using a depth-limited |
| 66 | + * search approach, increasing the depth limit iteratively until a solution is found |
| 67 | + * or it is confirmed that no solution exists. |
| 68 | + * |
| 69 | + * The implementation ensures that: |
| 70 | + * - The space complexity is efficient, as it avoids storing large states in memory. |
| 71 | + * - The time complexity is less than O(n^2) due to the iterative deepening approach. |
| 72 | + * - The original array remains unmodified throughout the process. |
| 73 | + * |
| 74 | + * If the puzzle is not solvable, the algorithm returns a message indicating this. |
| 75 | + * |
| 76 | + * @note The blank tile is represented by 0 in the puzzle. |
52 | 77 | */
|
| 78 | + |
53 | 79 | class Solve8TilePuzzle {
|
54 | 80 | public:
|
55 | 81 | vector<vector<int>> initialState, goalState; ///< Initial and goal states
|
|
0 commit comments