Skip to content

Commit ca8a229

Browse files
committed
comprehensive Doxygen-style comments for classes and methods.
1 parent 1499c7a commit ca8a229

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

search/Iterative_deepening_search_8_tile_puzzle.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include <bits/stdc++.h>
22
using namespace std;
3-
3+
/**
4+
* @file
5+
* @brief Implementation of Iterative deepening Search algorithm
6+
* @author [Sushant Kogurwar](https://github.com/sushskvnitn)
7+
*/
48
#define N 3 // Define the size of the tile puzzle (3x3)
59

610
/**
@@ -48,8 +52,30 @@ class Node {
4852

4953
/**
5054
* @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.
5277
*/
78+
5379
class Solve8TilePuzzle {
5480
public:
5581
vector<vector<int>> initialState, goalState; ///< Initial and goal states

0 commit comments

Comments
 (0)