0% found this document useful (0 votes)
15 views25 pages

Ada Project

The document presents a project on a 'Sudoku Solver using Backtracking Algorithm' as part of the Analysis and Design of Algorithms course at Visvesvaraya Technological University. It includes an introduction to pathfinding algorithms, a detailed problem statement, and a description of four algorithms: BFS, DFS, Dijkstra's, and A*. The project demonstrates the implementation of these algorithms to visualize pathfinding on a grid while avoiding obstacles, serving as an educational tool for understanding algorithmic concepts.

Uploaded by

sandeepsam247
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views25 pages

Ada Project

The document presents a project on a 'Sudoku Solver using Backtracking Algorithm' as part of the Analysis and Design of Algorithms course at Visvesvaraya Technological University. It includes an introduction to pathfinding algorithms, a detailed problem statement, and a description of four algorithms: BFS, DFS, Dijkstra's, and A*. The project demonstrates the implementation of these algorithms to visualize pathfinding on a grid while avoiding obstacles, serving as an educational tool for understanding algorithmic concepts.

Uploaded by

sandeepsam247
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

JNANASANGAMA, BELGAVI-590018

ANALYSIS AND DESIGN OF ALGORITHMS (BCS401)


on

“SUDOKU SOLVER USING BACKTRACKING ALGORITHM”


Submitted in partial fulfilment of the requirements for the 4th Semester
INFORMATION SCIENCE AND ENGINEERING
Submitted by

RAMYA R 1BI24IS445
TEJASHWINI K S 1BI24IS456
SAHANA K 1BI24IS447
SANDEEP R 1BI24IS451

Under the guidance of


Dr. S Mercy
Associate Professor
Department of ISE,
BIT, Bangalore.

DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
K. R. Road, V.V. Puram, Bengaluru-560004
2024-2025
BANGALORE INSTITUTE OF TECHNOLOGY
K.R. Road, V.V. Puram, Bengaluru -560004
DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING

CERTIFICATE

This is to certify that the implementation of ADA PROJECT (BCS401) entitled “SUDOKU
SOLVER USING BACKTRACKING ALGORITHM” has been successfully completed by
RAMYA R (1BI24IS445), TEJASHWINI K S (1BI24IS456), SAHANA K (1BI24IS447),
SANDEEP R (1BI24IS451) of IVth semester B.E. for the partial fulfilment of the requirements for
the Bachelor's degree in Information Science & Engineering of the Visvesvaraya Technological
University during the academic year 2024-2025.

Course Co-Ordinator:

Dr. S Mercy Signature with Date


Associate Professor
Department of ISE, BIT.
CONTENTS

Chapter No. Chapter Name Page No.


1 INTRODUCTION 1
2 PROBLEM STATEMENT 2
3 ALGORITHM 3-5
4 CODE 6-12
5 SNAPSHOTS 13-15
6 CONCLUSION 16
7 PPT SLIDES 17-21
CHAPTER 1
INTRODUCTION

Pathfinding algorithms are essential tools used in computer science to determine the best path
between two points. These algorithms have wide applications in fields like robotics, artificial
intelligence, gaming, and GPS navigation. In this project, we have implemented and visualized
four popular pathfinding algorithms: Breadth-First Search (BFS), Depth-First Search (DFS),
Dijkstra’s Algorithm, and A* (A-Star) Algorithm.

Each algorithm explores a grid from a given start point to an end point while avoiding obstacles.
The grid is represented as a 2D matrix where 0 indicates free space and 1 indicates obstacles.
The start and end positions are defined by the user, and the shortest or most efficient path is
calculated using the selected algorithm.

BFS (Breadth-First Search) explores level by level and guarantees the shortest path in
unweighted graphs.

DFS (Depth-First Search) goes deep into one direction first, and does not guarantee the
shortest path.

Dijkstra’s Algorithm works well with weighted grids and finds the shortest path based on
minimum cost.

A* Algorithm combines the actual cost with a heuristic (estimated distance) to find the path
more efficiently than Dijkstra.

By comparing the behavior of each algorithm visually, users can understand how different
strategies affect pathfinding performance. This project helps in understanding core algorithmic
concepts such as search strategy, graph traversal, heuristics, and cost optimization.

2024-25 1
Department of ISE

CHAPTER 2
PROBLEM STATEMENT
In many computational and real-life scenarios, finding a path from one point to another
while avoiding obstacles is a fundamental problem. Whether it's a robot navigating through
a warehouse, a GPS calculating a route, or an AI character in a game avoiding walls,
pathfinding is everywhere. In various real-world applications, the ability to find an optimal
path between two points while avoiding obstacles is essential.

These real-world applications range across multiple domains such as:

• Robotics: A robot navigating through a room filled with furniture or hazards.

• Video Games: Characters or enemies moving across maps with walls or traps.

• Navigation Systems: Finding the shortest driving or walking route from one
location to another.

• AI and Machine Learning: Simulating intelligent behavior through path


optimization.

• Computer Networks: Finding the least-cost path for data packets to travel across
routers.

Department of ISE 2024-25 2


2024-25 3
CHAPTER 3
ALGORITHM

Step 1: Create a grid of 10 rows and 10 columns.

Step 2: Let the user add obstacles on the grid by entering positions.

Step 3: Ask for the starting point and the end point from the user.

Step 4: Show the grid with:

. for open space

# for obstacles

S for the start

E for the end

Step 5: Ask the user to pick an algorithm:

BFS (Breadth-First Search)

DFS (Depth-First Search)

Dijkstra's Algorithm

A* (A-Star) Algorithm

Step 6: Based on the user’s choice:

The program tries to find a path from the start to the end, avoiding obstacles.

It marks the path with * on the grid.

Step 7: After the search:

If a path is found, it displays the grid with the path.

If not, it says “No Path Found!”

Step 8: The user can try again with a different algorithm or exit.

PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 4


1. BFS (Breadth-First Search) Algorithm

Initialize a queue and mark the start node as visited.

Enqueue the start node.

While the queue is not empty:

a. Dequeue a node from the front.

b. If it is the destination, trace back the path using the parent array.

c. For each of the 4 adjacent cells:

If the cell is valid and unvisited, mark it visited, set its parent, and enqueue it.

If the destination is reached, return success. Otherwise, return failure.

2. DFS (Depth-First Search) Algorithm

Initialize a stack and mark the start node as visited.

Push the start node onto the stack.

While the stack is not empty:

a. Pop the top node.

b. If it is the destination, trace back the path using the parent array.

c. For each of the 4 adjacent cells:

If the cell is valid and unvisited, mark it visited, set its parent, and push it.

If the destination is reached, return success. Otherwise, return failure.

3. Dijkstra's Algorithm

Initialize distance of all nodes as infinity except the start node, which is set to 0.

Insert the start node into a priority queue.

While the queue is not empty:

a. Extract the node with the smallest cost.

Department of ISE 2024-25 5


PATHFINDING ALGORITHMS VISUALIZER

b. If it is the destination, trace back the path.

c. For each valid adjacent cell:

Calculate new cost.

If new cost is lower, update distance, set parent, and push it to the queue.

Return success if destination is reached, else failure.

4. A* (A Star) Algorithm
Initialize g-cost of all nodes as infinity except start, which is 0.

Push the start node into the priority queue with f = g + heuristic.

While the queue is not empty:

a. Extract node with the lowest f-cost.

b. If it is the destination, trace the path.

c. For each valid adjacent cell:

Calculate g and f costs.

If new g-cost is better, update it, set parent, and push with new f to the queue.

Return success if destination is reached, else failure.

Department of ISE 2024-25 6


CHAPTER 5
SNAPSHOTS

Figure 5.1: Initial Grid Setup: Start and End Point with Obstacle Placement

Figure 5.2: Breadth-First Search (BFS) Pathfinding Result

Department of ISE 2024-25 13


PATHFINDING ALGORITHMS VISUALIZER

Figure 5.3: Depth-First Search (DFS) Pathfinding Result

Figure 5.4: Dijkstra’s Algorithm Pathfinding Result

Department of ISE 2024-25 14


PATHFINDING ALGORITHMS VISUALIZER

Figure 5.5: A* Algorithm Pathfinding Result and Exit Option

Department of ISE 2024-25 15


CHAPTER 6
CONCLUSION

This program effectively demonstrates how various pathfinding algorithms like BFS, DFS,
Dijkstra, and A* can be used to navigate a grid from a starting point (S) to an endpoint (E) while
avoiding obstacles. Each algorithm has its own way of exploring the grid: BFS uses a level-by-
level approach to find the shortest path, DFS goes deep and may not always find the most
efficient route, Dijkstra guarantees the shortest path by considering least cost, and A* combines
both distance and cost to find the optimal path more efficiently. By visualizing the paths taken
by each algorithm, the program offers a clear and practical understanding of how pathfinding
works in real-world scenarios like maps, games, and robotics. It serves as an educational tool
to compare algorithm behavior and efficiency in a simple, visual format.

Department of ISE 2024-25 16


CHAPTER 7
PPT SLIDES

Department of ISE 2024-25 17


Department of ISE 2024-25 18
PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 19


PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 20


PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 21


PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 22


PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 23


PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 24


PATHFINDING ALGORITHMS VISUALIZER

Department of ISE 2024-25 25

You might also like